public class Player
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private int |
hiddenCard
The player's one hidden card (a value 1..10).
|
(package private) java.lang.String |
name
The name of the player (used for printing purposes).
|
int |
sumOfVisibleCards
The sum of the player's cards, not counting the hidden card.
|
| Constructor and Description |
|---|
Player(java.lang.String name)
Constructs a player with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) int |
getScore()
Return this player's score (the total of all this player's cards).
|
(package private) boolean |
offerCard(Player[] players)
Decides whether to take another card.
|
(package private) void |
takeHiddenCard(int card)
Puts the specified card in this player's hand, and prints a
message saying that the card is being taken, but does not
print the value of the card.
|
(package private) void |
takeVisibleCard(int card)
Adds the given card to the visible cards for this Player, and
prints a message saying that the card is being taken.
|
java.lang.String name
private int hiddenCard
public int sumOfVisibleCards
public Player(java.lang.String name)
name - the name to be given to this player.boolean offerCard(Player[] players)
players - An array of all Players, including this one.true if the decision is to take another card.void takeVisibleCard(int card)
card - The card (1..10) being taken.void takeHiddenCard(int card)
card - the card received from the dealerint getScore()
Note: The way this program is organized, there is nothing to prevent another player from calling this routine to "cheat." Please don't do so. There are various ways to prevent cheating, but they all add complexity that we don't need in a program this small.