JavaScript is disabled on your browser.
C
D
F
G
H
M
N
O
P
R
S
T
C
controlPlay()
- Method in class simple21.
GameControl
Gives each player in turn a chance to take a card, until all players have passed.
createPlayers()
- Method in class simple21.
GameControl
Asks the human player for a name, and then creates a Human object and all the other Player objects, saving them in the
players
array.
D
deal()
- Method in class simple21.
GameControl
Deals the initial two cards (one hidden, one not hidden) to each player.
F
findWinningPlayer()
- Method in class simple21.
GameControl
Determines who won the game, and returns it as an index into the players array.
G
GameControl
- Class in
simple21
This is a simplified version of a common card game, "21".
GameControl()
- Constructor for class simple21.
GameControl
getScore()
- Method in class simple21.
Player
Return this player's score (the total of all this player's cards).
getYesOrNo(String)
- Method in class simple21.
Human
Returns a boolean response to a yes-no question.
H
hiddenCard
- Variable in class simple21.
Player
The player's one hidden card (a value 1..10).
Human
- Class in
simple21
Represents the human player in a game of Simple 21.
Human(String)
- Constructor for class simple21.
Human
Constructs a Human object to represent the user.
M
main(String[])
- Static method in class simple21.
GameControl
The main method just creates a GameControl object and calls its
run
method.
N
name
- Variable in class simple21.
Player
The name of the player (used for printing purposes).
nextCard()
- Method in class simple21.
GameControl
Returns a random "card", represented by a integer between 1 and 10, inclusive.
O
offerCard(Player[])
- Method in class simple21.
Human
Asks the user whether to take another card.
offerCard(Player[])
- Method in class simple21.
Player
Decides whether to take another card.
P
passed
- Variable in class simple21.
GameControl
passed[i] == true indicates that players[i] has passed.
Player
- Class in
simple21
Represents a player in this simplified version of the "21" card game.
Player(String)
- Constructor for class simple21.
Player
Constructs a player with the given name.
players
- Variable in class simple21.
GameControl
All the Player objects, including the Human player.
printResults()
- Method in class simple21.
GameControl
Prints a summary at the end of the game, saying how many points each player had, and who won.
R
random
- Variable in class simple21.
GameControl
A random number generator.
run()
- Method in class simple21.
GameControl
Prints a welcome method, then calls methods to perform each of the following actions: Create the Players (one of them a Human), Deal the initial two cards to each player, Control the play of the game, and Print the final results.
S
scanner
- Variable in class simple21.
GameControl
Used for getting input from the user.
scanner
- Variable in class simple21.
Human
showVisibleCards(Player[])
- Method in class simple21.
Human
Prints the sum of the visible cards for each player.
simple21
- package simple21
sumOfVisibleCards
- Variable in class simple21.
Player
The sum of the player's cards, not counting the hidden card.
T
takeHiddenCard(int)
- Method in class simple21.
Human
Takes a card that is not visible to the other players.
takeHiddenCard(int)
- Method in class simple21.
Player
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.
takeVisibleCard(int)
- Method in class simple21.
Player
Adds the given card to the visible cards for this Player, and prints a message saying that the card is being taken.
C
D
F
G
H
M
N
O
P
R
S
T