-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
52 lines (43 loc) · 1.17 KB
/
Player.java
File metadata and controls
52 lines (43 loc) · 1.17 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
class Player {
private String name;
private byte numberOfMatches; // count matches made in current round
private boolean myTurn;
private int roundCount; // count rounds won
public Player(String name) {
this.name = name;
this.numberOfMatches = 0;
this.myTurn = false;
this.roundCount = 0;
}
public String getName() {
return name;
}
public void setName(String newName) {
this.name = newName;
}
public byte getNumberOfMatches() {
return numberOfMatches;
}
public void resetNumberOfMatches() {
numberOfMatches = 0;
}
public void incrementMatches() {
numberOfMatches++;
}
public boolean isMyTurn() {
return myTurn;
}
public void setMyTurn(boolean myTurn) {
this.myTurn = myTurn;
}
public void hasWon(){
System.out.println("Congratulations " + this.getName() + ", you've won this round");
roundCount++;
}
public int getRoundCount() {
return roundCount;
}
public void resetRoundCount() {
roundCount = 0;
}
}