• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Java Help

Joined
Jun 6, 2004
Messages
9
//a. Write a method
//public void played(Soccerteam other, int myScore, int otherScore)
//that compares the numb of goals scored in a game by this and other teams and increments the appropriate fields (wins, losses, ties) in both teams.


//b. Write a method that returns the team's current number of points (each win is two points, each tie is one point). Write a reset method that zeroes out this team's wins, losses, and ties.

//c. Add fields to kep track of the total number of games played and the total number of goals scored by all teams in a trounament. Modify the played method from Part(a) to update these fields. Add static accessor methods for these fields and a static startTournament method to zero them out.

//d. Write a program that defines three teams, makes them play a few games with each other, then rerports eah tam's points as well as the total number of games played and the total number of goals scored by all teams in the tournament. The program then repeats this for another tournament.




Here's the thing: I am using a Java book to self-taught myself and so far I have been somewhat successful. I have managed to get a basic understanding of concepts, but as chapters advance I find it difficult to comprehend and code. There are times when I can disscet the code and figure out different parts, but unfortunately there isn't a CD or anything included with the book with sample code. I do like Java and have plans to enroll in my school's Java class, but before that I would like to get as much understanding of the subject as possible. Thanks.


And don't waste your time by accusing me of not trying, finding ways to not do my hw and posting before reading the chapter. I don't what is it - a person posts a problem and you get 10 different people accusing the person of lying.
 
I accuse you of not trying :eek:

:p

As for the question itself, well it look s quite straighfoward. My understanding is that you must have at this time a class called SoccerTeam or something similar. So why don't you just post up your class and I'll guide you through each one of those new features that you are trying to implement.

Cheers!
 
Actually you have to create a class Soccerteam. Do you call thinking as trying because I have been doing that for the past four hours, but haven't gotten anywhere. ;)

Maybe a skeletal structure of the program would be helpful and then I can try to fill in the blanks.
 
overclocker23 said:
Maybe a skeletal structure of the program would be helpful and then I can try to fill in the blanks.

If you've been able to do the other exercises, then you should at least be able to post SOMETHING for this problem rather than nothing.

--KK
 
Start by posting some pseudocode, the only difficult thing to understand perhaps is the idea of the "this" class, and passing classes to another classes methods...

First off, reading the problem statement you know you're going to have a class called Soccerteam, which you already know.

so, for example
Code:
class foo{
// methods
    // Stuff you want a foo to be able to do
    public void bar(int a, String b){
        // stuff
    }
// members
    // Stuff you want to store about a foo
    int foobar;
    String fooName;
}

Looking at the first problem, you should already know most of the class structure already. You're given one of the methods prototypes, and from the problem statement you should know some of the members.
 
Back
Top