ok so my friend has a final due...well later this morning in her computer science class. she sent me the instructions and im hoping somebody is better at this than me and can help me give her a framework for what she should do
Write a program that produces statistics for a baseball team.
Instructions:
Create the BaseballStats class:
It has two instance variables:
teamName, a String
battingAverages, an arrays of doubles
a
It has the following API:
Constructor:
public BaseballStats( String filename )
The team name and the batting averages for the team are stored in the file. You can assume the first item in the file is the team name (one word), followed by exactly 20 batting averages. Your constructor should read the file into the teamName and battingAverages array.
Methods:
public String getTeamName( )
accessor for teamName
public void setTeamName( String newTeamName )
mutator for teamName
public double maxAverage( )
returns the highest batting average
public double minAverage( )
returns the lowest batting average
public double spread( )
returns the difference between the highest and lowest batting averages
public int goodPlayers( )
returns the number of players with an average greater than .300
public String toString( )
returns a String containing the team name followed by all the batting averages formatted to three decimal places.
Client class:
Your client should instantiate an object of the BaseballStats class, passing the name of the text file containing the team name and the averages. The client should then call all methods, reporting the results as output.
Write a program that produces statistics for a baseball team.
Instructions:
Create the BaseballStats class:
It has two instance variables:
teamName, a String
battingAverages, an arrays of doubles
a
It has the following API:
Constructor:
public BaseballStats( String filename )
The team name and the batting averages for the team are stored in the file. You can assume the first item in the file is the team name (one word), followed by exactly 20 batting averages. Your constructor should read the file into the teamName and battingAverages array.
Methods:
public String getTeamName( )
accessor for teamName
public void setTeamName( String newTeamName )
mutator for teamName
public double maxAverage( )
returns the highest batting average
public double minAverage( )
returns the lowest batting average
public double spread( )
returns the difference between the highest and lowest batting averages
public int goodPlayers( )
returns the number of players with an average greater than .300
public String toString( )
returns a String containing the team name followed by all the batting averages formatted to three decimal places.
Client class:
Your client should instantiate an object of the BaseballStats class, passing the name of the text file containing the team name and the averages. The client should then call all methods, reporting the results as output.