The compiler cannot find my 'getters'

angelo_xtreme

New Member
I am modeling a baseball team with both a Player class and a Team class. Player has a few of each player's statistics (name, number, batting average, etc.), and Team has an array of Player objects, the team name and the size of the team.I created an array of Player objects in Team.java, and used a simple 'for' loop to search through my array. However, I get multiple compile time errors that say that the compiler cannot find any of my 'getters' that are in Player.java.Here is my battingAverage method that uses such a loop in Team.java:\[code\]public double battingAverage () { double sum = 0.0; for (int i = 0; i<size; i++) { sum = sum + team.getAverage; } return (sum / size);}\[/code\]And here is the 'getter' in Player.java\[code\]public double getAverage () { return average;}\[/code\](average is declared as a private dynamic field and is given a value by the constructor)This is the error the compiler gives me:\[code\]./Team.java:21: cannot find symbolsymbol : variable getAveragelocation: class Player sum = sum + team.getAverage; ^\[/code\]This type of error repeats for all of the 'getters' that I use in Team.java (getPosition, getName, etc.).However, I know that the compiler recognizes team as a singular Player object because I also get the following error:\[code\] ./Team.java:21: operator + cannot be applied to double,Player.getAverage sum = sum + team.getAverage; ^\[/code\]So it seems to me that for some reason, getAverage just cannot be found in Player.java and I cannot figure out why.Any help you can offer would be much appreciated.
 
Back
Top