2. This is the project README file. Here, you should describe
your project.
Tell the reader (someone who does not know anything about this
project)
all he/she needs to know. The comments should usually include
at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
__MACOSX/sports-team/._README.TXT
sports-team/SportsTeam.classpublicsynchronizedclass
SportsTeam {
private java.util.Vector opponent;
private java.util.Vector home;
private java.util.Vector teamPoints;
private java.util.Vector oppPoints;
private String teamName;
3. private String sportName;
public void SportsTeam();
public void changeSport(String);
public void changeName(String);
public void addGame(String, boolean, int, int);
public void updateGame(int, String, boolean, int, int);
public double getWinLoss(boolean);
public void displayRecord();
public void addRandomGames(int, int);
}
__MACOSX/sports-team/._SportsTeam.class
sports-team/SportsTeam.ctxt
#BlueJ class context
comment0.params=
comment0.target=SportsTeam()
comment0.text=rn Constructor for objects of class
SportsTeamrn
comment1.params=newSport
comment1.target=void changeSport(java.lang.String)
comment1.text=rn Method to change sport. rn
comment2.params=newName
comment2.target=void changeName(java.lang.String)
comment2.text=rn Method to change team name. rn
4. comment3.params=otherTeam homeGame ourPoints
theirPoints
comment3.target=void addGame(java.lang.String, boolean,
int, int)
comment3.text=rn Method to add a new game. Attempts
to add a game with either score negativern should be
rejected with an error message in the terminal
wondow.rn
comment4.params=position otherTeam homeGame ourPoints
theirPoints
comment4.target=void updateGame(int, java.lang.String,
boolean, int, int)
comment4.text=rn Method to update data for a game
that wwas entered in error. The game data at the
positionrn provided will be replaced with the data
provided. Aagin, negative scores should be rjected rn
with an error message, as should any invalid position.rn
comment5.params=printRequested
comment5.target=double getWinLoss(boolean)
comment5.text=rn When this method is called, the
win/loss poercentage for the team will always be
computed rn and returned.rn rn In addition, if the
printRequested parameter is true, team's overall win-loss
record rn should be displayed in the terminal window
in the following format: rn Win-Loss Record:
games_won-games_lost (% won)rn rn
Example:rn Win-Loss Record: 38-26
(59.375%)rn
5. comment6.params=
comment6.target=void displayRecord()
comment6.text=rn Dpisplay the team's current record,
one line per game. Each line should begin with fourrn
spaces, then display the following: the game number
followed by a colon, the opposing rn team name (with
"@" proceeding the name for away games), "W" or "L"
indicating win or rn loss, and the score of each team,
separated by a hyphen. NOTE: The home team score is
rn always dosplayed last. After all games are displayed,
the win-loss record should be rn displayed. (Call the
method above to include this.)rn rn Here is an
example:rn rn Record for the Greens baseball
team:rn 0: @Flyers L 5-7rn 1: Raiders W
2-7rn 2: Vikings W 5-6rn 3: @Cardinals
W 5-3rn Win-loss Record: 3-1 (75.0%)rn rn
comment7.params=numGames maxScore
comment7.target=void addRandomGames(int, int)
comment7.text=rn Create ramdom simulated game data
for the team. Parameters are used to specify the
nuimberrn of games to generate and the maximum score
expected in each game (as this would vary byrn
sport.rn
numComments=8
__MACOSX/sports-team/._SportsTeam.ctxt
6. sports-team/SportsTeam.javasports-
team/SportsTeam.javaimport java.util.*;
/**
* A SportsTeam object will track the record of a sports team, u
sing several "paralell
* vectors". For each of these vectors, position i will contain the
information for
* the ith game played by the team. Those vectors are:
*
* opponent - Contains the name of the opposing team.
* home -
Is true if the game is a home game, false if the game is an away
game.
* teamPoints - The number of points acored by the team.
* oppPoints -
The number of points scored by the opposing team.
*
* @author (your name)
* @version (a version number or a date)
*/
publicclassSportsTeam
{
// These vectors will be used to track games. For each, position
i will contain
// the information for game i;
privateVector<String> opponent;
privateVector<Boolean> home;
privateVector<Integer> teamPoints;
privateVector<Integer> oppPoints;
// Fields to hold name of team and sport.
privateString teamName;
privateString sportName;
/**
* Constructor for objects of class SportsTeam
7. */
publicSportsTeam()
{
// Create all the vectors.
opponent =newVector<String>();
home =newVector<Boolean>();
teamPoints =newVector<Integer>();
oppPoints =newVector<Integer>();
// Default team name and sport.
teamName ="Greens";
sportName ="baseball";
}
/**
* Method to change sport.
*/
publicvoid changeSport(String newSport)
{
// Your code goes here.
}
/**
* Method to change team name.
*/
publicvoid changeName(String newName)
{
// Your code goes here.
}
/**
* Method to add a new game. Attempts to add a game with ei
ther score negative
* should be rejected with an error message in the terminal w
ondow.
*/
8. publicvoid addGame(String otherTeam,boolean homeGame,int o
urPoints,int theirPoints)
{
// Your code goes here.
}
/**
* Method to update data for a game that wwas entered in err
or. The game data at the position
* provided will be replaced with the data provided. Aagin, n
egative scores should be rjected
* with an error message, as should any invalid position.
*/
publicvoid updateGame(int position,String otherTeam,boolean h
omeGame,int ourPoints,int theirPoints)
{
// Your code goes here.
}
/**
* When this method is called, the win/loss poercentage for t
he team will always be computed
* and returned.
*
* In addition, if the printRequested parameter is true, team's
overall win-loss record
* should be displayed in the terminal window in the followin
g format:
* Win-Loss Record: games_won-games_lost (% won)
*
* Example:
* Win-Loss Record: 38-26 (59.375%)
*/
publicdouble getWinLoss(boolean printRequested)
{
// Your code goes here. (The line below will be replaced.)
9. return0.0;
}
/*
* Dpisplay the team's current record, one line per game. Eac
h line should begin with four
* spaces, then display the following: the game number follo
wed by a colon, the opposing
* team name (with "@" proceeding the name for away games
), "W" or "L" indicating win or
* loss, and the score of each team, separated by a hyphen. N
OTE: The home team score is
* always dosplayed last. After all games are displayed, the w
in-loss record should be
* displayed. (Call the method above to include this.)
*
* Here is an example:
*
* Record for the Greens baseball team:
* 0: @Flyers L 5-7
* 1: Raiders W 2-7
* 2: Vikings W 5-6
* 3: @Cardinals W 5-3
* Win-loss Record: 3-1 (75.0%)
*
*/
publicvoid displayRecord()
{
// Display heading.
System.out.println("Record for the "+teamName+" "+sportName
+" team:");
// Your code goes here.
}
/**
* Create ramdom simulated game data for the team. Paramet
10. ers are used to specify the nuimber
* of games to generate and the maximum score expected in e
ach game (as this would vary by
* sport.
*/
publicvoid addRandomGames(int numGames,int maxScore)
{
String[] teams ={"Flyers","Raiders","Vikings","Cardinals"};
boolean[] trueFalse ={true,false};
int i, pos1, pos2, score1, score2;
System.out.println("Adding the following games:");
for(i=0; i<numGames; i++)
{
pos1 =(int)(Math.random()*4);
pos2 =(int)(Math.random()*2);
score1 =(int)(Math.random()*(maxScore+1));
score2 = score1;
while(score2 == score1)
score2 =(int)(Math.random()*(maxScore+1));
System.out.println(" "+teams[pos1]+" "+trueFalse[pos2]+" "+
score1+" "+score2);
addGame(teams[pos1], trueFalse[pos2], score1, score2);
}
}
}
__MACOSX/sports-team/._SportsTeam.java
__MACOSX/._sports-team