forked from MosheOfer1/OOP_EX1_2025
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.java
64 lines (57 loc) · 1.74 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
52
53
54
55
56
57
58
59
60
61
62
63
64
public abstract class Player {
protected boolean isPlayerOne; // Indicates whether the player is a defender or attacker
protected int wins;
protected static final int initial_number_of_bombs = 3;
protected static final int initial_number_of_unflippedable = 2;
protected int number_of_bombs;
protected int number_of_unflippedable;
public Player(boolean isPlayerOne) {
this.isPlayerOne = isPlayerOne;
reset_bombs_and_unflippedable();
wins = 0;
}
/**
* Determines whether this player is Player 1.
*
* @return true if the player is Player 1, false if the player is Player 2 (or any other player).
*/
public boolean isPlayerOne() {
return isPlayerOne;
}
/**
* Retrieves the number of wins accumulated by this player over the course of the game.
*
* @return The total number of wins achieved by the player.
*/
public int getWins() {
return wins;
}
/**
* Increment the win counter by one when the player wins a round or match.
*/
public void addWin() {
this.wins++;
}
/**
* Determines whether this player is human.
*
* @return true if the player is human.
*/
abstract boolean isHuman();
public int getNumber_of_bombs() {
return number_of_bombs;
}
public int getNumber_of_unflippedable() {
return number_of_unflippedable;
}
public void reduce_bomb() {
number_of_bombs--;
}
public void reduce_unflippedable() {
number_of_unflippedable--;
}
public void reset_bombs_and_unflippedable() {
this.number_of_bombs = initial_number_of_bombs;
this.number_of_unflippedable = initial_number_of_unflippedable;
}
}