samples/apifest1/day2/inputandoperation/src/org/netbeans/apifest/boolcircuit/VariableInput.java
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/apifest1/day2/inputandoperation/src/org/netbeans/apifest/boolcircuit/VariableInput.java Sat Jun 14 09:52:45 2008 +0200
1.3 @@ -0,0 +1,44 @@
1.4 +/*
1.5 + * VariableInput.java
1.6 + *
1.7 + * Created on July 13, 2006, 3:02 PM
1.8 + *
1.9 + * To change this template, choose Tools | Template Manager
1.10 + * and open the template in the editor.
1.11 + */
1.12 +
1.13 +package org.netbeans.apifest.boolcircuit;
1.14 +
1.15 +/**
1.16 + *
1.17 + * @author mkleint
1.18 + */
1.19 +public final class VariableInput extends Input {
1.20 +
1.21 + private double value;
1.22 +
1.23 + /** Creates a new instance of VariableInput */
1.24 + VariableInput() {
1.25 + value = 0f;
1.26 + }
1.27 +
1.28 + public void setBooleanValue(boolean bool) {
1.29 + value = bool ? 1d : 0d;
1.30 + }
1.31 +
1.32 + public boolean getBooleanValue() {
1.33 + return value == 1d;
1.34 + }
1.35 +
1.36 + public double getRealValue() {
1.37 + return value;
1.38 + }
1.39 +
1.40 + public void setRealValue(double real) throws IllegalArgumentException {
1.41 + if (real < 0d || real > 1d) {
1.42 + throw new IllegalArgumentException();
1.43 + };
1.44 + value = real;
1.45 + }
1.46 +
1.47 +}