Class Dice

java.lang.Object
  extended by Dice

public class Dice
extends Object

Represents a dice with a specified number of sides


Constructor Summary
Dice()
          Constructs a standard dice with 6 sides
Dice(int numberOfSides)
          Constructs a dice with a specified number of sides
 
Method Summary
 int getValue()
          To access the value
static void main(String[] args)
          A small test program
 int roll()
          Makes a random change of the value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dice

public Dice()
Constructs a standard dice with 6 sides


Dice

public Dice(int numberOfSides)
Constructs a dice with a specified number of sides

Parameters:
numberOfSides - number of sides
Throws:
RuntimeException - if non positive number of sides
Method Detail

roll

public int roll()
Makes a random change of the value

Returns:
the new value

getValue

public int getValue()
To access the value

Returns:
the current value

main

public static void main(String[] args)
A small test program