如何开始这个项目

How to get started on this project?

本文关键字:项目 开始 何开始      更新时间:2024-03-16

我很难理解我的项目说明,英语是我的第二语言,所以有人能帮助我分解它并帮助我如何进行这个项目吗?

项目摘要
编写一个为棒球队生成统计数据的程序。

说明:

创建BaseballStats类:

它有两个实例变量:
teamName,字符串
battingAverages,一组双打,代表球队中所有球员的平均打击率。

该类具有以下API:

构造函数:

  public BaseballStats( String filename )

球队名称和球队的打击率存储在文件中。你可以假设文件中的第一项是球队名称(一个单词——没有空格),后面紧跟着正好20个打击率。构造函数应该将文件读取到teamName实例变量和battingAverages数组中。

方法:

 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 higher than .300
 public String toString( )
     returns a String containing the team name followed by all the batting averages formatted to three decimal places.  

客户端类别:

您的客户端应该实例化BaseballStats类的一个对象,传递包含团队名称和平均值的文本文件的名称。然后,客户端应该调用所有方法,并将结果报告为输出。

根据您的评论判断,您可能从未使用过Java。以下是它应该如何布局:

class BaseballStats {
private String filename;
public BaseballStats ( String filename )
{
    this.filename = filename;
}
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 higher than .300
}
public String toString( )
{
//returns a String containing the team name followed by all the batting averages formatted to three decimal places. 
}
}

您的客户端(同一目录中的另一个java文件)可以使用创建此类的实例

BaseballStats newTeam = new BaseballStats(filename);