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

  1.  
  2. package simula.random;
  3.  
  4. import java.util.Random;
  5.  
  6. /**
  7.  * The class Value is the value extracted from the pseudo-random generator.
  8.  * It encapsulate either boolean, integer or real values. The three implementation
  9.  * of this class supply infact these values. Trying to get the wrong type of
  10.  * value fires an exception. The class Value fires exception in every case.
  11.  * @see draw
  12.  * @see BooleanValue
  13.  * @see IntegerValue
  14.  * @see RealValue
  15.  */
  16. public class Value {
  17.   
  18.  
  19.     /**
  20.      * Returns a boolean representation of the value. If it is meaningless
  21.      * fires an Exception.
  22.      * @return a boolean representation of the value. If it is meaningless
  23.      * fires an Exception.
  24.      * @exception TypeDrawnException fired if meaningless.     
  25.      */  
  26.     public boolean asBoolean() throws TypeDrawnException {
  27.         throw new TypeDrawnException(TypeDrawnException.TYPE_MISMATCH);
  28.     }
  29.     /**
  30.      * Returns an integer representation of the value. If it is meaningless
  31.      * fires an Exception.
  32.      * @return an integer representation of the value. If it is meaningless
  33.      * fires an Exception.
  34.      * @exception TypeDrawnException fired if meaningless.     
  35.      */  
  36.     public int asInteger() throws TypeDrawnException { 
  37.         throw new TypeDrawnException(TypeDrawnException.TYPE_MISMATCH);
  38.     }
  39.     /**
  40.      * Returns a real representation of the value. If it is meaningless
  41.      * fires an Exception.
  42.      * @return a real representation of the value. If it is meaningless
  43.      * fires an Exception.
  44.      * @exception TypeDrawnException fired if meaningless.
  45.      */        
  46.     public double asReal() throws TypeDrawnException { 
  47.         throw new TypeDrawnException(TypeDrawnException.TYPE_MISMATCH);
  48.     }
  49. }