Class Game

java.lang.Object
  |
  +--Game

public class Game
extends java.lang.Object

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.

Version:
0
Author:
David Matuszek, (Students: replace this with your name)

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
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dealer

static Dealer dealer
The Dealer object.

player1

static Player player1
One of the three players.

player2

static Player player2
One of the three players.

player3

static Player player3
One of the three players.
Constructor Detail

Game

public Game()
Method Detail

main

public 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. Note: Things must be created in this order, since the constructor for Players requires a Game object, and the constructor for Dealer requires the three Player objects.


Generated by BlueJ