-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.java
More file actions
185 lines (165 loc) · 4.37 KB
/
Player.java
File metadata and controls
185 lines (165 loc) · 4.37 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package models;
/**
*
*/
public class Player {
private String playerName;
private int numberOfCarrots, numberOfLettuces, playerBoardPosition, squareCounter, messageCounter;
private boolean isFinished, skipNextTurn;
/**
* Constructor for objects of class Player
*
* @param playerName Name of the player
*/
public Player(String playerName) {
this.setPlayerName(playerName);
setNumberOfCarrots(2085);
this.numberOfLettuces = 0;
}
/**
* Method to get a player's name
*
* @return the player's name
*/
public String getPlayerName() {
return playerName;
}
/**
* Method to change a player's name.
*
* @param playerName - the new name for the player
*/
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
/**
* Method to get the number of carrots a player has
*
* @return the number of carrots the player has
*/
public int getNumberOfCarrots() {
return numberOfCarrots;
}
/**
* Method to update the number of carrots a player has
*
* @param numberOfCarrots - the new number of carrots for the player
*/
public void setNumberOfCarrots(int numberOfCarrots) {
this.numberOfCarrots = numberOfCarrots;
}
/**
* Method to get the number of lettuces a player has left
*
* @return the number of lettuce the player has left
*/
public int getNumberOfLettuces() {
return numberOfLettuces;
}
/**
* Method to update the number of lettuces a player has
*
* @param numberOfLettuces the new amount of lettuces remaining. Decrements by one
*/
public void chewALettuce() {
this.numberOfLettuces--;
}
/**
* Method to get a player's current board position
*
* @return the player's current board position
*/
public int getPlayerBoardPosition() {
return playerBoardPosition;
}
/**
* Method to move a player to a new board position
*
* @param playerBoardPosition - the player's new board position
*/
public void setPlayerBoardPosition(int playerBoardPosition) {
this.playerBoardPosition = playerBoardPosition;
}
/**
*
* Method to remove players from the turn sequence once they have reached the finish square
*
* @return returns true if the player has reached the final square and therefor is no longer included
* in the turn sequence
*
*/
public boolean isFinished() {
return isFinished;
}
public void setFinished() {
this.isFinished = true;
}
/**
* Method to return a string listing the player's attributes
*
* @return a string listing the player's attributes
*/
public String toString() {
return "Player: " + playerName +
"\nCarrots: " + numberOfCarrots +
"\tLettuces: " + numberOfLettuces +
"\nBoard Position: " + playerBoardPosition;
}
/**
*
* Method to determine the number of turns a player has been at a certain square
* significant to Lettuce and Number Squares
* @return the squareCounter
*/
public int getSquareCounter() {
return squareCounter;
}
/**
* Method to increase the square counter
*
* @param squareCounter the squareCounter to set
*/
public void setSquareCounter(int squareCounter) {
this.squareCounter = squareCounter;
}
/**
*Method to invoke skipping of turns
*
* @return returns true if the player is to skip the next turn
*/
public boolean isSkipNextTurn() {
return skipNextTurn;
}
/**
* Method to skip turn as caused by hare cards or lettuce squares
* @param skipNextTurn false by default until the player has to miss a turn
*
*/
public void setSkipNextTurn(boolean skipNextTurn) {
this.skipNextTurn = skipNextTurn;
}
/**
*
* @return a message to display carrots to other players when this hare card is drawn
*/
public String showMessage() {
return playerName + " has " + numberOfCarrots + " carrots!";
}
/**
*
* Method controls the show carrots message display to each player once
*
* @return the amount of players that have seen the show carrots message
*/
public int getMessageCounter() {
return messageCounter;
}
/**
*Method to control the message loop to cycle over all players once
*
* @param messageCounter The message counter increments until it reaches the number of players
*/
public void setMessageCounter(int messageCounter) {
this.messageCounter = messageCounter;
}
}