-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.java
More file actions
95 lines (87 loc) · 2.16 KB
/
Copy pathPlayer.java
File metadata and controls
95 lines (87 loc) · 2.16 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Player in the Connect Four game
*
* @author Sean DeZurik
*/
public class Player {
/** How many total pieces played by a player */
private int piecesPlayed;
/** Max consecutive pieces on the board by a player */
private int maxConsecutivePieces;
/** Color of player's pieces */
private String color;
/** Name of the player */
private String name;
/** Player1 or Player2 */
private int playerNumber;
/**
* Constructor for Player
*
* @param name the name of the player
* @param color the color of the player's pieces
* @param playerNumber whether 1 or 2
*/
public Player(String name, String color, int playerNumber) {
this.name = name;
this.color = color;
this.playerNumber = playerNumber;
piecesPlayed = 0;
maxConsecutivePieces = 0;
}
/**
* Get total number of pieces played by player
*
* @return int with number of pieces played
*/
public int getPiecesPlayed() {
return piecesPlayed;
}
/**
* Get max consecutive pieces on board by player
*
* @return int with number of max consecutive pieces
*/
public int getMaxConsecutivePieces() {
return maxConsecutivePieces;
}
/**
* Increase number of pieces played by one
*/
public void incrementPiecesPlayed() {
piecesPlayed++;
}
/**
* Set the max number of consecutive pieces
*
* @param count the number of consecutive pieces
*/
public void setMaxConsecutivePieces(int count) {
if (count > maxConsecutivePieces) {
maxConsecutivePieces = count;
}
}
/**
* Get the player's color
*
* @return String with player's color
*/
public String getColor() {
return color;
}
/**
* Get the player's name
*
* @return String with the player's name
*/
public String getName() {
return name;
}
/**
* Get the player number, 1 or 2
*
* @return int with the player number
*/
public int getPlayerNumber() {
return playerNumber;
}
}