Nur die besten Spiele ;3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
861 B

package TicTacToe;
import java.awt.Color;
import javax.swing.JLabel;
public class Scoreboard extends JLabel{
private static final long serialVersionUID = 1L;
public int[] playerPoints;
public Scoreboard(int _playerCount) {
playerPoints = new int[_playerCount];
setForeground(Color.white);
updateScores();
}
public void addPoint(int playerID) {
playerPoints[playerID]++;
updateScores();
}
public void subPoint(int playerID) {
playerPoints[playerID]--;
updateScores();
}
public void updateScores() {
int gamesPlayed = 0;
for(int i = 0; i < playerPoints.length; i++){
if(i == 0) {
setText("Draws: " + playerPoints[0]);
} else {
setText(getText() + " Player " + i + ": " + playerPoints[i]);
}
gamesPlayed += playerPoints[i];
}
setText(getText() + " Games played: " + gamesPlayed);
}
}