-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.java
More file actions
47 lines (39 loc) · 947 Bytes
/
Counter.java
File metadata and controls
47 lines (39 loc) · 947 Bytes
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
package connect4;
/**
* Counter class
*/
public class Counter {
private Player player; // player that own's the counter
/**
* Constructor. Assigns the player object
*/
public Counter(Player player) {
this.player = player;
}
/**
* Player getter
*
* @return player object
*/
public Player getPlayer() {
return player;
}
public String toString() {
return player.getSymbol() + "";
}
/**
* Compares given object with the current instance. If the other's object player
* is the same as the instance's player - then return true
*/
public boolean equals(Object o) {
if (!(o instanceof Counter)) {
return false;
} else {
Counter other = (Counter) o;
if (player == other.getPlayer()) {
return true;
} else
return false;
}
}
}