blue.chance
Class Die

java.lang.Object
  |
  +--blue.chance.Die

public class Die
extends java.lang.Object

A 'die' is modeled in terms of a top face value, the number of sides, a name, and a history of previous roll outcomes from a particular point in 'time'.


Constructor Summary
Die()
          Create a standard die.
Die(int nf)
          Create a standard die.
Die(java.lang.String n)
          Create a standard die.
Die(java.lang.String n, int nf)
          Create a standard die.
 
Method Summary
 int count()
          Return the number of values on the local event history.
 int previous()
          Return the previously rolled top face value, assuming there is one.
 int previous(int n)
          Return the nth previously rolled top face value, assuming it exists.
 void print()
          Print a representation of the die to the standard output stream.
 void print(OutStream os)
          Print a representation of the die to the standard output stream.
 void print(java.io.PrintStream ps)
          Print a representation of the die to the standard output stream.
 void println()
          Print a description of the die to the standard output stream followed by a newline.
 void println(OutStream os)
          Print a description of the die to the standard output stream followed by a newline.
 void println(java.io.PrintStream ps)
          Print a description of the die to the standard output stream followed by a newline.
 void reset()
          Empty the local history which records the top face outcomes since either the die was created or a reset command was issued.
 void roll()
          Roll the die.
 void showHistory()
          Display the local event history (the top face values) to the standard output file.
 void showHistory(OutStream os)
          Display the local event history (the top face values) to the standard output file.
 void showHistory(java.io.PrintStream ps)
          Display the local event history (the top face values) to the standard output file.
 void showHistoryHorizontally()
          Display the local event history (the top face values) to the standard output file, horizontally.
 void showHistoryHorizontally(OutStream os)
          Display the local event history (the top face values) to the standard output file, horizontally.
 void showHistoryHorizontally(java.io.PrintStream ps)
          Display the local event history (the top face values) to the standard output file, horizontally.
 void showHistoryVertically()
          Display the local event history (the top face values) to the standard output file, vertically.
 void showHistoryVertically(OutStream os)
          Display the local event history (the top face values) to the standard output file, vertically.
 void showHistoryVertically(java.io.PrintStream ps)
          Display the local event history (the top face values) to the standard output file, vertically.
 int top()
          Return the top face value of the die.
 void topPrint()
          Print the top face value of the die to the standard output stream.
 void topPrint(OutStream os)
          Print the top face value of the die.
 void topPrint(java.io.PrintStream ps)
          Print the top face value of the die.
 void topPrintln()
          Print the top face value of the die to the standard output stream followed by a newline.
 void topPrintln(OutStream os)
          Print the top face value of the die to the standard output stream followed by a newline.
 void topPrintln(java.io.PrintStream ps)
          Print the top face value of the die to the standard output stream followed by a newline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Die

public Die()
Create a standard die.

Die

public Die(java.lang.String n)
Create a standard die.
Parameters:
n - the name of the die.

Die

public Die(int nf)
Create a standard die.
Parameters:
nf - the number of faces.

Die

public Die(java.lang.String n,
           int nf)
Create a standard die.
Parameters:
n - the name of the die.
nf - the number of faces.
Method Detail

roll

public void roll()
Roll the die.

top

public int top()
Return the top face value of the die.

topPrint

public void topPrint()
Print the top face value of the die to the standard output stream.

topPrint

public void topPrint(OutStream os)
Print the top face value of the die.
Parameters:
os - the stream to which the value is written.

topPrint

public void topPrint(java.io.PrintStream ps)
Print the top face value of the die.
Parameters:
ps - the stream to which the value is written.

print

public void print()
Print a representation of the die to the standard output stream.

print

public void print(OutStream os)
Print a representation of the die to the standard output stream.
Parameters:
os - the stream to which the value is written.

print

public void print(java.io.PrintStream ps)
Print a representation of the die to the standard output stream.
Parameters:
ps - the stream to which the value is written.

topPrintln

public void topPrintln()
Print the top face value of the die to the standard output stream followed by a newline.

topPrintln

public void topPrintln(OutStream os)
Print the top face value of the die to the standard output stream followed by a newline.
Parameters:
os - the stream to which the value is written.

topPrintln

public void topPrintln(java.io.PrintStream ps)
Print the top face value of the die to the standard output stream followed by a newline.
Parameters:
ps - the stream to which the value is written.

reset

public void reset()
Empty the local history which records the top face outcomes since either the die was created or a reset command was issued.

count

public int count()
Return the number of values on the local event history.

println

public void println()
Print a description of the die to the standard output stream followed by a newline.

println

public void println(OutStream os)
Print a description of the die to the standard output stream followed by a newline.
Parameters:
os - the stream to which the value is written.

println

public void println(java.io.PrintStream ps)
Print a description of the die to the standard output stream followed by a newline.
Parameters:
ps - the stream to which the value is written.

showHistory

public void showHistory()
Display the local event history (the top face values) to the standard output file.

showHistory

public void showHistory(OutStream os)
Display the local event history (the top face values) to the standard output file.
Parameters:
os - the stream to which the value is written.

showHistory

public void showHistory(java.io.PrintStream ps)
Display the local event history (the top face values) to the standard output file.
Parameters:
ps - the stream to which the value is written.

showHistoryHorizontally

public void showHistoryHorizontally()
Display the local event history (the top face values) to the standard output file, horizontally.

showHistoryHorizontally

public void showHistoryHorizontally(OutStream os)
Display the local event history (the top face values) to the standard output file, horizontally.
Parameters:
os - the stream to which the value is written.

showHistoryHorizontally

public void showHistoryHorizontally(java.io.PrintStream ps)
Display the local event history (the top face values) to the standard output file, horizontally.
Parameters:
ps - the stream to which the value is written.

showHistoryVertically

public void showHistoryVertically()
Display the local event history (the top face values) to the standard output file, vertically.

showHistoryVertically

public void showHistoryVertically(OutStream os)
Display the local event history (the top face values) to the standard output file, vertically.
Parameters:
os - the stream to which the value is written.

showHistoryVertically

public void showHistoryVertically(java.io.PrintStream ps)
Display the local event history (the top face values) to the standard output file, vertically.
Parameters:
ps - the stream to which the value is written.

previous

public int previous()
Return the previously rolled top face value, assuming there is one.

previous

public int previous(int n)
Return the nth previously rolled top face value, assuming it exists.
Parameters:
n - the index in time gone by of the top face value to be retured.