console
Class Dice

java.lang.Object
  extended byconsole.Dice

public class Dice
extends Object

A class to generate random numbers of various sorts. d() is a n-sided die numbered 0 to n-1. This is the most common use of this class.


Constructor Summary
Dice(int si)
          Make a die with this many number of sides.
 
Method Summary
static boolean coin()
           
static boolean coin(float per)
          An unfair coin.
static int d(int what)
          Return number from 0 to what-1, inclusive (i.e. [0, what)
static double f(double max)
          Return double from 0 to max.
static double f(double min, double max)
          Return double from min to max.
static float f(float max)
          Return float from 0 to max.
static float f(float min, float max)
          Return float from min to max.
static void main(String[] args)
           
static boolean percent(float per)
          Have a per chance of returning true.
static void reset()
           
 int roll()
          Return a number between 0 and the number of sides of the die minus one.
static void setSeed(long val)
           
static long setSeedLock()
          Reset random number generator and returned the used seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dice

public Dice(int si)
Make a die with this many number of sides.

Method Detail

roll

public int roll()
Return a number between 0 and the number of sides of the die minus one.


d

public static int d(int what)
Return number from 0 to what-1, inclusive (i.e. [0, what)


coin

public static boolean coin()
Returns:
if a coin flipped heads.

coin

public static boolean coin(float per)
An unfair coin.

Parameters:
per - Chance of true. In [0,1].

percent

public static boolean percent(float per)
Have a per chance of returning true.

Parameters:
per - Percent, in [0,1] (i.e. expressed as decimal.)

f

public static float f(float max)
Return float from 0 to max.


f

public static float f(float min,
                      float max)
Return float from min to max.


f

public static double f(double max)
Return double from 0 to max.


f

public static double f(double min,
                       double max)
Return double from min to max.


setSeedLock

public static long setSeedLock()
Reset random number generator and returned the used seed. Calling reset will put it back to this value.


reset

public static void reset()

setSeed

public static void setSeed(long val)

main

public static void main(String[] args)