A BowlScores object
keeps track of a bowler’s name, number of games bowled and the scores for those
games. The handling of this data will be as follows.
private String name; // name of the bowler
private int numGames;
// the number of games bowled
private int[] gameScores;
// list of scores for the bowler
public BowlScores(String
nm, int nGames)
// Sets name to nm, numGames to nGames and sizes the array to nGames
public String getName()
// Returns the name of the bowler
public int getNumGames()
// Returns the number of games stored in the object
public int[] getBowlScores()
// Returns an array containing all of the bowling scores
public int getScore(int n)
// Returns bowling score n from
gameScores
public int getTotal()
// Returns the total of all scores in gameScores
public double getAverage()
// Returns the average of all scores in gameScores
public void setName(String
nm)
// Sets the name to the value in String nm
public void setGameScore(int gameNum, int
newScore)
// Sets game gameNum
in gameScores to the score newScore
public String toString()
// Returns a String containing the object’s data
// The result should be as shown in the example
below
Bowler: Chuck
Game 1: 178
Game 2: 192
Game 3: 185
Game 4: 183
Total: 738
Average: 184.5