com.stevesoft.pat.apps
Class Deck

java.lang.Object
  |
  +--com.stevesoft.pat.apps.Deck

public class Deck
extends java.lang.Object

An interface to java.util.Random which simulates a deck of "cards." Actually, it just supplies random numbers from 0 to ncards()-1 without ever repeating a number. Thus, you can think of each integer in this range as a card.


Field Summary
 java.util.Random r
          The random number generator this class uses.

 
Constructor Summary
Deck(int ncards)
          Initialize the size of the deck.
 
Method Summary
 void discard(int n)
           
 int draw()
           
 int ncards()
          The number of cards remaining in this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

r

public java.util.Random r
The random number generator this class uses.
Constructor Detail

Deck

public Deck(int ncards)
Initialize the size of the deck. The deck has a number of cards equal to "ncards" in it.
Method Detail

ncards

public int ncards()
The number of cards remaining in this object.

discard

public void discard(int n)

draw

public int draw()