samples/apifest1/day2/inputandoperation/src/org/netbeans/apifest/boolcircuit/VariableInput.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:52:45 +0200
changeset 52 4257f4cf226b
permissions -rw-r--r--
Adding samples from API fest to the repository, including pieces of their code in the document, not just links
     1 /*
     2  * VariableInput.java
     3  *
     4  * Created on July 13, 2006, 3:02 PM
     5  *
     6  * To change this template, choose Tools | Template Manager
     7  * and open the template in the editor.
     8  */
     9 
    10 package org.netbeans.apifest.boolcircuit;
    11 
    12 /**
    13  *
    14  * @author mkleint
    15  */
    16 public final class VariableInput extends Input {
    17     
    18     private double value;
    19     
    20     /** Creates a new instance of VariableInput */
    21     VariableInput() {
    22         value = 0f;
    23     }
    24     
    25     public void setBooleanValue(boolean bool) {
    26         value = bool ? 1d : 0d;
    27     }
    28     
    29     public boolean getBooleanValue() {
    30         return value == 1d;
    31     }
    32 
    33     public double getRealValue() {
    34         return value;
    35     }
    36     
    37     public void setRealValue(double real) throws IllegalArgumentException {
    38         if (real < 0d || real > 1d) {
    39             throw new IllegalArgumentException();
    40         };
    41         value = real;
    42     }
    43     
    44 }