I think I am really close I just cant get the code to change the status of the game to game over from the In progress status. Can somebody point me into the right direction please. I don't somebody to do it for me I just have tried everything that I can think of, I know it's something simple but I'm just not seeing it. Thanks in advance for the help. BasketballGameDemo.zip
I attempted to attach the program itself if that is a help.
public class BasketballGame {
private String firstTeamName;
private String secondTeamName;
private int firstTeamScore;
private int secondTeamScore;
private String gameStatus;
String winnersName = "";
public BasketballGame(String firstTeamName, String secondTeamName) {
this.firstTeamName = firstTeamName;
this.secondTeamName = secondTeamName;
this.firstTeamScore = 0;
this.secondTeamScore = 0;
this.gameStatus = "In progress";
}
public String getFirstTeamName() {
return firstTeamName;
}
public int getFirstTeamScore() {
return firstTeamScore;
}
public String getGameStatus() {
return gameStatus;
}
public String getSecondTeamName() {
return secondTeamName;
}
public int getSecondTeamScore() {
return secondTeamScore;
}
public void setFirstTeamScoreOnePoint() {
this.firstTeamScore = +1;
}
public void setFirstTeamScoreTwoPoints() {
this.firstTeamScore += 2;
}
public void setFirstTeamScoreThreePoints() {
this.firstTeamScore += 3;
}
public void setSecondTeamScoreOnePoint() {
this.secondTeamScore = +1;
}
public void setSecondTeamScoreTwoPoints() {
this.secondTeamScore += 2;
}
public void setSecondTeamScoreThreePoints() {
this.secondTeamScore += 3;
}
public String determineWinner() {
if (this.firstTeamScore > this.secondTeamScore) {
winnersName = this.firstTeamName;
} else {
winnersName = this.secondTeamName ;
}
return winnersName;
}
public BasketballGame()
{
while (winnersName.equals(firstTeamName) || winnersName.equals(secondTeamName))
{
gameStatus = "Game Over";
}
}
@Override
public String toString() {
return "BasketballGame{" + "First Team :" + firstTeamName
+ ", Second Team :" + secondTeamName
+ firstTeamName + " = " + firstTeamScore + " "
+ secondTeamName + " = " + secondTeamScore + " "
+ ", Game Status = " + gameStatus + '}';
}
}
public class BasketballGameDemo {
public static void main(String[] args)
{
BasketballGame game1 = new BasketballGame("Cats","Dogs");
game1.setFirstTeamScoreOnePoint();
game1.setFirstTeamScoreTwoPoints();
game1.setFirstTeamScoreThreePoints();
game1.setFirstTeamScoreOnePoint();
game1.setFirstTeamScoreTwoPoints();
game1.setFirstTeamScoreThreePoints();
// System.out.println(game1.toString());
game1.setSecondTeamScoreTwoPoints();
game1.setSecondTeamScoreThreePoints();
game1.setSecondTeamScoreThreePoints();
System.out.println(game1);
System.out.println("The winner is " + game1.determineWinner());