-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
51 lines (42 loc) · 1.14 KB
/
Player.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package BridgeBuilderAdv;
/**
* The Player class represents a player in the BridgeBuilder game.
* A player has a token that shows where they've made their moves.
* At the end of the game, the scores will be returned to show the Player's total points.
* @author chaejinhur
*
*/
public class Player {
private char token;
private int score;
// constructor for Player
public Player() {
this.token = '+'; // token for marking player's moves
this.score = 0; // player's score initialized
}
// places the player's token on the game board at specified row
public void makeMove(GameBoard board, int row, int col) {
board.placeToken(row, col, token); // place the player's token on the board to make a move
}
/**
* Returns the plaeyr's token
* @return the player's token
*/
public char getToken() {
return token;
}
/**
* Returns the player's score
* @return the player's current score
*/
public int getScore() {
return score;
}
/**
* Adds the specified increment to the score
* @param increment the score increment
*/
public void addScore (int increment) {
score += increment;
}
}