Browse Source

Add Games played to Scoreboard

feature_TicTacToe_Scoreboard
kfkama 3 years ago
parent
commit
41b70d2700
  1. 5
      src/main/java/TicTacToe/Scoreboard.java
  2. 2
      src/main/java/TicTacToe/TicTacToeGame.java

5
src/main/java/TicTacToe/Scoreboard.java

@ -24,13 +24,18 @@ public class Scoreboard extends JLabel{
} }
public void updateScores() { public void updateScores() {
int gamesPlayed = 0;
for(int i = 0; i < playerPoints.length; i++){ for(int i = 0; i < playerPoints.length; i++){
if(i == 0) { if(i == 0) {
setText("Draws: " + playerPoints[0]); setText("Draws: " + playerPoints[0]);
} else { } else {
setText(getText() + " Player " + i + ": " + playerPoints[i]); setText(getText() + " Player " + i + ": " + playerPoints[i]);
} }
gamesPlayed += playerPoints[i];
} }
setText(getText() + " Games played: " + gamesPlayed);
} }

2
src/main/java/TicTacToe/TicTacToeGame.java

@ -60,7 +60,7 @@ public class TicTacToeGame extends JPanel {
private void initScoreboard() { private void initScoreboard() {
scoreboard = new Scoreboard(maxPlayers); scoreboard = new Scoreboard(maxPlayers);
scoreboard.setBounds(200, 100, 200, 50);
scoreboard.setBounds(150, 100, 300, 50);
add(scoreboard); add(scoreboard);
} }

Loading…
Cancel
Save