dice
Class Die

java.lang.Object
  |
  +--dice.Die

public class Die
extends java.lang.Object


Field Summary
static int BADVAL
           
static int defaultSides
           
static int maxSides
           
static int minSides
           
 
Constructor Summary
Die()
          Creates a new default instance of Die - with 6 sides and no initial value
Die(int sides)
          Creates a new instance of Die - with a given number of sides and no initial value
Die(int sides, int val)
          Creates a new instance of Die - with a given number of sides and given initial value
 
Method Summary
 boolean equals(java.lang.Object obj)
          test if two die objects are equal (in contents) Policy - just check value shown on dice - makes easier for client code to check die for having a particular value
 int getNumSides()
          report the number of sides on this die (you think I'm joking - there are other size dice besides 6 sided)
 int getRoll()
          roll the dice and report the value shown on the die
 int getValue()
          report on what the current value shown on the dice is
static void main(java.lang.String[] args)
           
 dice.Die roll()
           
 java.lang.String toString()
          show the current value shown on the die (Policy - user not interested in how many sides - they know that) Policy - bad value - show as #BAD#
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BADVAL

public static final int BADVAL
See Also:
Constant Field Values

minSides

public static final int minSides
See Also:
Constant Field Values

maxSides

public static final int maxSides
See Also:
Constant Field Values

defaultSides

public static final int defaultSides
See Also:
Constant Field Values
Constructor Detail

Die

public Die()
Creates a new default instance of Die - with 6 sides and no initial value


Die

public Die(int sides)
Creates a new instance of Die - with a given number of sides and no initial value


Die

public Die(int sides,
           int val)
Creates a new instance of Die - with a given number of sides and given initial value

Method Detail

getValue

public int getValue()
report on what the current value shown on the dice is


getRoll

public int getRoll()
roll the dice and report the value shown on the die


roll

public dice.Die roll()

getNumSides

public int getNumSides()
report the number of sides on this die (you think I'm joking - there are other size dice besides 6 sided)


equals

public boolean equals(java.lang.Object obj)
test if two die objects are equal (in contents) Policy - just check value shown on dice - makes easier for client code to check die for having a particular value

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
show the current value shown on the die (Policy - user not interested in how many sides - they know that) Policy - bad value - show as #BAD#

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments used to test class