net.sourceforge.webcompmath.data
Class ValueMath

java.lang.Object
  extended by net.sourceforge.webcompmath.data.ValueMath
All Implemented Interfaces:
java.io.Serializable, Value
Direct Known Subclasses:
WCMValueMathBean

public class ValueMath
extends java.lang.Object
implements Value

A ValueMath object is an easy way to create Value objects that are computed from other Value objects. For example, "new ValueMath(a,b,'+')" is an object whose value is obtained by adding the values of a and b.

See Also:
Serialized Form

Constructor Summary
ValueMath()
          Default constructor, only used in GUI builders.
ValueMath(Function f, Value x)
          Create a ValueMath object whose value is computed as f(x).
ValueMath(Value x, Value y, char op)
          Create a ValueMath object whose value is computed by applying an arithmetic operator the values of x and y.
 
Method Summary
 double getVal()
          Get the value of this object.
 void setFunction(Function f)
          Set the function to use
 void setop(char op)
          Set the operation to use
 void setX(Value x)
          Set the X value to use
 void setY(Value y)
          Set the Y value to use
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueMath

public ValueMath(Value x,
                 Value y,
                 char op)
Create a ValueMath object whose value is computed by applying an arithmetic operator the values of x and y.

Parameters:
x - first arg. value
y - second arg. value
op - The arithmetic operator that is to be applied to x and y. This should be one of the characters '+', '-', '*', '/', or '^'. (No error is thrown if another character is provided. It will be treated as a '/').

ValueMath

public ValueMath(Function f,
                 Value x)
Create a ValueMath object whose value is computed as f(x).

Parameters:
f - function to use
x - value to use

ValueMath

public ValueMath()
Default constructor, only used in GUI builders.

Method Detail

setX

public void setX(Value x)
Set the X value to use

Parameters:
x - the value to use

setY

public void setY(Value y)
Set the Y value to use

Parameters:
y - the value to use

setop

public void setop(char op)
Set the operation to use

Parameters:
op - the operation to use

setFunction

public void setFunction(Function f)
Set the function to use

Parameters:
f - the function to use

getVal

public double getVal()
Get the value of this object.

Specified by:
getVal in interface Value
Returns:
value