Hi!
I'm working on a school project and ran into a problem.
We're creating an ArrayList of basketball games where each game is set up as:
public Game (String homeTeam, int htScore, String opponent, int oppScore)
{
this.homeTeam = homeTeam;
this.htScore = htScore;
this.opponent = opponent;
this.oppScore = oppScore;
}
One of the tasks is to find the average of the Home team scores.
I don't understand how to go through and just select that element from the index.
Right now I have:
int homesum = 0;
for (int i = 0; i < this.size(); i++)
{
homesum = homesum + Integer.parseInt(theDB.get(i).htScore);
}
but I realize that won't work.
Any help would be appreciated.
Thanks!