|
|
@ -0,0 +1,36 @@ |
|
|
|
package TicTacToe; |
|
|
|
|
|
|
|
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]; |
|
|
|
} |
|
|
|
|
|
|
|
public void addPoint(int playerID) { |
|
|
|
playerPoints[playerID]++; |
|
|
|
updateScores(); |
|
|
|
} |
|
|
|
|
|
|
|
public void subPoint(int playerID) { |
|
|
|
playerPoints[playerID]--; |
|
|
|
updateScores(); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateScores() { |
|
|
|
for(int i = 0; i < playerPoints.length; i++){ |
|
|
|
if(i == 0) { |
|
|
|
setText("Draws: " + playerPoints[0]); |
|
|
|
} else { |
|
|
|
setText(getText() + " Player " + i + ": " + playerPoints[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |