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

  1.  
  2. package simula.random;
  3.  
  4. /**
  5.  * Implementation of the class Value that encapsulate real values.
  6.  * @see Value
  7.  */
  8. public class IntegerValue extends Value {
  9.  
  10.     private int value;
  11.  
  12.  
  13.     /**
  14.      * Creates a new object encapsulating the given integer value.
  15.      * @param v The integer value to encapsulate.
  16.      */
  17.     IntegerValue(int v) {
  18.         value = v;
  19.     }
  20.     /**
  21.      * Returns the encapsulated integer number.
  22.      * @return the encapsulated integer number.
  23.      * @exception TypeDrawnException Fired whenever meaningless
  24.      */
  25.     public int asInteger() throws TypeDrawnException {
  26.         return value;
  27.     }
  28.     /**
  29.      * Returns the encapsulated integer value converted to a floating point number.
  30.      * @return the encapsulated integer value converted to a floating point number.
  31.      * @exception TypeDrawnException Fired whenever meaningless
  32.      */
  33.     public double asReal() throws TypeDrawnException {
  34.         return (double)value;
  35.     }
  36. }