java.lang.Object | +--Game
This is a simplified version of a common card game, "21".
In this game, the dealer deals two "cards" to each player, one hidden, so that only the player knows what it is, and one face up, so that everyone can see it. (Actually, what the other players see is the total of each other's cards, not the individual cards.)
The players then take turns requesting cards, trying to get as close to 21 as possible, but not going over 21. A player may pass (ask for no more cards). Once a player has passed, he or she cannot later ask for another card. When all three players have passed, the game ends.
The winner is the player who has come closest to 21 without exceeding it. In the case of a tie, or if everyone goes over 21, no one wins.
In this program, we further simplify things by assuming that there is one dealer (who does not play) and exactly three players. The game is only played once. Students: Once you get the basic game running, feel free to remove some or all of these restrictions.
| Field Summary | |
(package private) static Dealer |
dealer
The Dealer object. |
(package private) static Player |
player1
One of the three players. |
(package private) static Player |
player2
One of the three players. |
(package private) static Player |
player3
One of the three players. |
| Constructor Summary | |
Game()
|
|
| Method Summary | |
static void |
main(java.lang.String[] args)
The main method creates the Game, three Players, and the Dealer, then asks the Dealer to run the game. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static Dealer dealer
static Player player1
static Player player2
static Player player3
| Constructor Detail |
public Game()
| Method Detail |
public static void main(java.lang.String[] args)