home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / JSL.ZIP / JSL20 / simula / random / Generator.java < prev    next >
Encoding:
Java Source  |  1998-02-20  |  1.5 KB  |  55 lines

  1.  
  2. package simula.random;
  3.  
  4. import java.util.Random;
  5.  
  6. /**
  7.  * The abstract class Generator is the common parent of the hierarchy
  8.  * of the classes implementing generators with different distribution.
  9.  * Every implementation of this class offers the possibility to draw
  10.  * integer, real or boolean values according to the chosen distribution.
  11.  * The class RandomEngine is the source of the pseudo-random bits.
  12.  * Every implementation should define its own constructors in a proper
  13.  * way such that its paramaters would be properly initialized.
  14.  * @author Dalcorso Luca, Fin Alessando, Riva Nicola
  15.  * @see RandomEngine
  16.  */
  17. public abstract class Generator {
  18.  
  19.         /**
  20.          * Identifies a boolean valued generator.
  21.          */
  22.         public static final int BOOLEAN_TYPE = 0;
  23.  
  24.         /**
  25.          * Identifies an integer valued generator.
  26.          */
  27.         public static final int INTEGER_TYPE = 1;
  28.  
  29.         /**
  30.          * Identifies a real valued generator.
  31.          */
  32.         public static final int REAL_TYPE = 2;
  33.  
  34.         /**
  35.          * Source of the pseudo-random bits.
  36.          */
  37.         protected RandomEngine random;
  38.  
  39.  
  40.         /**
  41.          * Draws a value from the generator: its type can be read with the <code>type</code> method.
  42.          * @return Value object encapsulating the drawed value.
  43.          * @see Value
  44.          */
  45.         public abstract Value draw();
  46.         /**
  47.          * Abstract method that allows to identify the type of the value.
  48.          * Every implementation must provide this method.
  49.          * @return Type of the values extracted.
  50.          * @see REAL_TYPE
  51.             * @see INTEGER_TYPE
  52.             * @see BOOLEAN_TYPE
  53.          */
  54.         public abstract int type();
  55. }