Class Dealer

java.lang.Object
  |
  +--Dealer

public class Dealer
extends java.lang.Object

Represents the dealer in this simplified version of the "21" card game.

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

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

Field Detail

name

java.lang.String name
The name of the dealer (used only for printing purposes).

player1

Player player1
One of the three players.

player2

Player player2
One of the three players.

player3

Player player3
One of the three players.

random

java.util.Random random
A random number generator.
Constructor Detail

Dealer

public 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.
Parameters:
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

allowPlay

void allowPlay()
Gives each player in turn a chance to play, until all three players have passed.

deal

void deal()
Deals the initial two cards (one hidden, one not hidden) to each player.

nextCard

int nextCard()
Returns a random "card" (represented by a integer between 1 and 10, inclusive). For simplicity, all cards are equally likely, and there are an infinite number of cards (so this is more like rolling a 10-sided die than like drawing from a 52-card deck). Note: The java.util package contains a Random class, which is perfect for generating random numbers.
Returns:
a random integer in the range 1..10.

runGame

void runGame()
Calls methods to perform the following three actions:
  1. Deals the initial two cards to each player,
  2. Gives each player a chance to play, in turn, until all three players have passed, and
  3. Determines the winner.

scoreGame

void scoreGame()
Determines and prints out the winner.


Generated by BlueJ