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
jtulach@52
     1
/*
jtulach@52
     2
 * VariableInput.java
jtulach@52
     3
 *
jtulach@52
     4
 * Created on July 13, 2006, 3:02 PM
jtulach@52
     5
 *
jtulach@52
     6
 * To change this template, choose Tools | Template Manager
jtulach@52
     7
 * and open the template in the editor.
jtulach@52
     8
 */
jtulach@52
     9
jtulach@52
    10
package org.netbeans.apifest.boolcircuit;
jtulach@52
    11
jtulach@52
    12
/**
jtulach@52
    13
 *
jtulach@52
    14
 * @author mkleint
jtulach@52
    15
 */
jtulach@52
    16
public final class VariableInput extends Input {
jtulach@52
    17
    
jtulach@52
    18
    private double value;
jtulach@52
    19
    
jtulach@52
    20
    /** Creates a new instance of VariableInput */
jtulach@52
    21
    VariableInput() {
jtulach@52
    22
        value = 0f;
jtulach@52
    23
    }
jtulach@52
    24
    
jtulach@52
    25
    public void setBooleanValue(boolean bool) {
jtulach@52
    26
        value = bool ? 1d : 0d;
jtulach@52
    27
    }
jtulach@52
    28
    
jtulach@52
    29
    public boolean getBooleanValue() {
jtulach@52
    30
        return value == 1d;
jtulach@52
    31
    }
jtulach@52
    32
jtulach@52
    33
    public double getRealValue() {
jtulach@52
    34
        return value;
jtulach@52
    35
    }
jtulach@52
    36
    
jtulach@52
    37
    public void setRealValue(double real) throws IllegalArgumentException {
jtulach@52
    38
        if (real < 0d || real > 1d) {
jtulach@52
    39
            throw new IllegalArgumentException();
jtulach@52
    40
        };
jtulach@52
    41
        value = real;
jtulach@52
    42
    }
jtulach@52
    43
    
jtulach@52
    44
}