home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.2 KB | 44 lines |
-
- package simula.random;
-
- /**
- * Implementation of the class Value that encapsulate boolean values.
- * @see Value
- */
- public class BooleanValue extends Value {
-
- private boolean value = false;
-
-
- /**
- * Creates a new object encapsulating the given boolean value.
- * @param b The boolean value to encapsulate.
- */
- BooleanValue(boolean b) {
- value = b;
- }
- /**
- * Returns the encapsulated boolean.
- * @return the encapsulated boolean.
- * @exception TypeDrawnException Fired whenever meaningless
- */
- public boolean asBoolean() throws TypeDrawnException {
- return value;
- }
- /**
- * Returns the encapsulated boolean represented as an integer value.
- * @return 1 if the encapsulated boolean is true; 0 otherwise.
- * @exception TypeDrawnException Fired whenever meaningless
- */
- public int asInteger() throws TypeDrawnException {
- return value ? 1 : 0;
- }
- /**
- * Returns the encapsulated boolean represented as a real value.
- * @return 1.0 if the encapsulated boolean is true; 0.0 otherwise.
- * @exception TypeDrawnException Fired whenever meaningless
- */
- public double asReal() throws TypeDrawnException {
- return value ? 1.0 : 0.0;
- }
- }