java.lang.Object | +--Dealer
Represents the dealer in this simplified version of the "21" card game.
| Field Summary | |
(package private) java.lang.String |
name
The name of the dealer (used only for printing purposes). |
(package private) Player |
player1
One of the three players. |
(package private) Player |
player2
One of the three players. |
(package private) Player |
player3
One of the three players. |
(package private) java.util.Random |
random
A random number generator. |
| Constructor Summary | |
Dealer(java.lang.String name,
Player player1,
Player player2,
Player player3)
Takes the name of the dealer and the three Players and saves them in the instance variables. |
|
| Method Summary | |
(package private) void |
allowPlay()
Gives each player in turn a chance to play, until all three players have passed. |
(package private) void |
deal()
Deals the initial two cards (one hidden, one not hidden) to each player. |
(package private) int |
nextCard()
Returns a random "card" (represented by a integer between 1 and 10, inclusive). |
(package private) void |
runGame()
Calls methods to perform the following three actions: Deals the initial two cards to each player, Gives each player a chance to play, in turn, until all three players have passed, and Determines the winner. |
(package private) void |
scoreGame()
Determines and prints out the winner. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
java.lang.String name
Player player1
Player player2
Player player3
java.util.Random random
| Constructor Detail |
public Dealer(java.lang.String name,
Player player1,
Player player2,
Player player3)
name - the name of this dealer.player1 - the name of the first player.player2 - the name of the second player.player3 - the name of the third player.| Method Detail |
void allowPlay()
void deal()
int nextCard()
Random
class, which is perfect for generating random numbers.void runGame()
void scoreGame()