package dbleagueswing;
/**
* Team Class - this class is the template for each team in our World Cup Application
* when instantiated the class takes in the teams name and the teams skill as constructor parameters.
* @author Ross Nesbitt
*/
public class Team
{
//
// Class Properties
//
private int tablePos = 0; //positio * @author Ross Nesbittn in the table the team holds
private String teamName; //name of the team
private int gamesPlayed = 0; //number of games played
private int gamesWon = 0; //number of games won
private int gamesLost = 0; // number of games lost
private int gamesDrawn = 0; //number of games drawn
private int goalsFor = 0; //number of goals for
private int goalsAgainst = 0; //number of goals against
private int goalDiff = 0; //the goal difference
private int tablePoints = 0; //number of points a team has
/**
* Constructor - teamDraw(Team Name, Team Skill)
* Takes the parameters in and creates an instance with a teamName and teamSkill.
* @param TeamName - set the Team's name.
* @param teamSkill - set the Team's skill.
*/
public Team(String tablePos, String teamName, String gamesPlayed, String gamesWon, String gamesDrawn, String gamesLost, String goalsFor, String goalsAgainst, String goalDiff, String tablePoints)
{ this.tablePos = Integer.parseInt(tablePos);
this.teamName = teamName;
this.gamesPlayed = Integer.parseInt(gamesPlayed);
this.gamesWon = Integer.parseInt(gamesWon);
this.gamesDrawn = Integer.parseInt(gamesDrawn);
this.gamesLost = Integer.parseInt(gamesLost);
this.goalsFor = Integer.parseInt(goalsFor);
this.goalsAgainst = Integer.parseInt(goalsAgainst);
this.goalDiff = Integer.parseInt(goalDiff);
this.tablePoints = Integer.parseInt(tablePoints);
}
//
// Methods
//
//
// Accessor methods
//
/**
* Set the value of tablePos
* @param newVar the new value of tablePos
*/
public void setTablePos ( int newVar )
{
tablePos = newVar;
}
/**
* Get the value of tablePos
* @return the value of tablePos
*/
public int getTablePos ( )
{
return tablePos;
}
/**
* Set the value of teamName
* @param newVar the new value of teamName
*/
public void setTeamName ( String newVar )
{
teamName = newVar;
}
/**
* Get the value of teamName
* @return the value of teamName
*/
public String getTeamName ( )
{
return teamName;
}
/**
* Set the value of gamesPlayed
* @param newVar the new value of gamesPlayed
*/
public void setGamesPlayed ( int newVar )
{
gamesPlayed = newVar;
}
/**
* Get the value of gamesPlayed
* @return the value of gamesPlayed
*/
public int getGamesPlayed ( )
{
return gamesPlayed;
}
/**
* Set the value of gamesWon
* @param newVar the new value of gamesWon
*/
public void setGamesWon ( int newVar )
{
gamesWon = newVar;
}
/**
* Get the value of gamesWon
* @return the value of gamesWon
*/
public int getGamesWon ( )
{
return gamesWon;
}
/**
* Set the value of gamesLost
* @param newVar the new value of gamesLost
*/
public void setGamesLost ( int newVar )
{
gamesLost = newVar;
}
/**
* Get the value of gamesLost
* @return the value of gamesLost
*/
public int getGamesLost ( )
{
return gamesLost;
}
/**
* Set the value of gamesDrawn
* @param newVar the new value of gamesDrawn
*/
public void setGamesDrawn ( int newVar )
{
gamesDrawn = newVar;
}
/**
* Get the value of gamesDrawn
* @return the value of gamesDrawn
*/
public int getGamesDrawn ( )
{
return gamesDrawn;
}
/**
* Set the value of goalsFor
* @param newVar the new value of goalsFor
*/
public void setGoalsFor ( int newVar )
{
goalsFor = newVar;
}
/**
* Get the value of goalsFor
* @return the value of goalsFor
*/
public int getGoalsFor ( )
{
return goalsFor;
}
/**
* Set the value of goalsAgainst
* @param newVar the new value of goalsAgainst
*/
public void setGoalsAgainst ( int newVar )
{
goalsAgainst = newVar;
}
/**
* Get the value of goalsAgainst
* @return the value of goalsAgainst
*/
public int getGoalsAgainst ( )
{
return goalsAgainst;
}
/**
* Set the value of goalDiff
* @param newVar the new value of goalDiff
*/
public void setGoalDiff ( int newVar )
{
goalDiff = newVar;
}
/**
* Get the value of goalDiff
* @return the value of goalDiff
*/
public int getGoalDiff ( )
{
return goalDiff;
}
/**
* Set the value of tablePoints
* @param newVar the new value of tablePoints
*/
public void setTablePoints ( int newVar )
{
tablePoints = newVar;
}
/**
* Get the value of tablePoints
* @return the value of tablePoints
*/
public int getTablePoints ( )
{
return tablePoints;
}
//
// Other methods
//
/**
* Method - teamWin(Goals For, Goals against)
* Adds three points to tablePoints increments gamesPlayed and gamesWon by 1
* the method also takes the parameters and adjusts the goal difference
* @param gFor Goals For
* @param gAgainst Goals Against
*/
public void teamWin( int gFor, int gAgainst )
{
setGoalsFor(getGoalsFor() + gFor); //and the parameter to goals for for this instance
setGoalsAgainst(getGoalsAgainst() + gAgainst); //and the parameter to goals against for this instance
setGoalDiff(0); //reset the teams goal differenece
setGoalDiff(getGoalsFor() - getGoalsAgainst()); //create new goal difference goals for - goals against
int points = getTablePoints() + 3; //set integer variable to 3 for points for win
setTablePoints(points); //add the points to the team
setGamesPlayed(getGamesPlayed() + 1); //increase games played by one
setGamesWon(getGamesWon() + 1); //increase games won by one
}
/**
* Method - teamLose(Goals For, Goals against)
* Adds no points to tablePoints increments gamesPlayed and gamesLost by 1
* the method also takes the parameters and adjusts the goal difference
* @param gFor Goals For
* @param gAgainst Goals Against
*/
public void teamLose( int gFor, int gAgainst )
{
setGoalsFor(getGoalsFor() + gFor); //and the parameter to goals for for this instance
setGoalsAgainst(getGoalsAgainst() + gAgainst); //and the parameter to goals against for this instance
setGoalDiff(0); //reset the teams goal differenece
setGoalDiff(getGoalsFor() - getGoalsAgainst()); //create new goal difference goals for - goals against
setGamesPlayed(getGamesPlayed() + 1); //increase games played by one
setGamesLost(getGamesLost() + 1); //increase games lost by one
}
/**
* Method - teamDraw(Goals For, Goals against)
* Adds one point to tablePoints increments gamesPlayed and gamesWon by 1
* the method also takes the parameters and adjusts the goal difference
* @param gFor Goals For
* @param gAgainst Goals Against
*/
public void teamDraw( int gFor, int gAgainst )
{
setGoalsFor(getGoalsFor() + gFor); //and the parameter to goals for for this instance
setGoalsAgainst(getGoalsAgainst() + gAgainst); //and the parameter to goals against for this instance
setGoalDiff(0); //reset the teams goal differenece
setGoalDiff(getGoalsFor() - getGoalsAgainst()); //create new goal difference goals for - goals against
setTablePoints(getTablePoints() + 1); //add one point to the team for a draw
setGamesPlayed(getGamesPlayed() + 1); //increase games played by one
setGamesDrawn(getGamesDrawn() + 1); //increase games drawn by one
}
@Override
public String toString(){
return "Position " + this.tablePos +
"/nTeam Name " + this.teamName +
"/nGames Played " + this.gamesPlayed +
"/nGames Won " + this.gamesWon +
"/nGames Drawn " + this.gamesDrawn +
"/nGames Lost " + this.gamesLost +
"/nGoals For " + this.goalsFor +
"/nGoals Against " + this.goalsAgainst +
"/nGoal DIfference " + this.goalDiff +
"/nTable Points " + this.tablePoints
;
}
}