-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
28 lines (22 loc) · 850 Bytes
/
Player.java
File metadata and controls
28 lines (22 loc) · 850 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
import java.util.ArrayList;
import java.util.List;
//Represents a player in the game with a hand of cards and sets won.
public class Player {
private List<Card> hand = new ArrayList<>(); // The player's current hand of cards
private int setsWon = 0; // The number of sets the player has won
public List<Card> getHand() {
return hand; // Returns the player's current hand
}
public void addCard(Card card) {
hand.add(card); // Adds a card to the player's hand
}
public void resetHand() {
hand.clear(); // Clears the player's hand (used at the start of a new round)
}
public int getSetsWon() {
return setsWon; // Returns the number of sets the player has won
}
public void incrementSetsWon() {
setsWon++; // Increments the number of sets won by the player
}
}