| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.webcompmath.data.Constant
public class Constant
A Constant is a Value that represents a constant real number. (The value doesn't have to be constant in sub-classes, since the member that stores the value is protected, not private.) A Constant doesn't necessarily need a name. If the name is null, then the print string for the Constant is the value of the constant. If it has a non-null name, then the print string is the name. (Note that, as for any MathObject, if the name is null, than the Constant can't be added to a Parser.) Constant objects are used to represent the mathematical constants pi and e. A Constant is both an Expression and an ExpressionCommand. Since it is an ExpressionCommand, it can occur as a command in an ExpressionProgram. In that case, it simply represens a named constant occurs in an expression.
| Field Summary | |
|---|---|
protected  double | 
value
The value of this Constant.  | 
| Constructor Summary | |
|---|---|
Constant()
default constructor, intended only for use in GUI building  | 
|
Constant(double value)
Create an unnamed Constant with the given value and null name.  | 
|
Constant(java.lang.String name,
         double value)
Create a Constant with the given name and value.  | 
|
| Method Summary | |
|---|---|
 void | 
appendOutputString(ExpressionProgram prog,
                   int myIndex,
                   java.lang.StringBuffer buffer)
Append the print string for this Constant to the buffer.  | 
 void | 
apply(StackOfDouble stack,
      Cases cases)
Apply the Constant to the stack.  | 
 void | 
compileDerivative(ExpressionProgram prog,
                  int myIndex,
                  ExpressionProgram deriv,
                  Variable wrt)
Add a commands to deriv to evaluate the derivative of this Constant with respect to the variable.  | 
 boolean | 
dependsOn(Variable x)
Return false, since the value of this Constant is independent of the value of x.  | 
 Expression | 
derivative(Variable wrt)
Return the derivative of this Constant with respect to the variable wrt.  | 
 int | 
extent(ExpressionProgram prog,
       int myIndex)
Return the number of locations that this Constant uses in the program.  | 
 java.lang.String | 
getName()
Return the name of this Constant.  | 
 double | 
getVal()
Return the value of this Constant.  | 
 double | 
getValueWithCases(Cases cases)
Return the value of the Constant.  | 
 void | 
setName(java.lang.String name)
Set the name of this Constant.  | 
 java.lang.String | 
toString()
Return the print string representing this Constant.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected double value
| Constructor Detail | 
|---|
public Constant()
public Constant(double value)
value - value to use
public Constant(java.lang.String name,
                double value)
name - name of constantvalue - it's value| Method Detail | 
|---|
public java.lang.String getName()
getName in interface MathObjectpublic void setName(java.lang.String name)
setName in interface MathObjectname - name of the constantpublic double getVal()
getVal in interface Valuepublic double getValueWithCases(Cases cases)
getValueWithCases in interface Expressioncases - the cases to use
public Expression derivative(Variable wrt)
derivative in interface Expressionwrt - variable wirh respect to
public java.lang.String toString()
toString in interface ExpressiontoString in class java.lang.Object
public void apply(StackOfDouble stack,
                  Cases cases)
apply in interface ExpressionCommandstack - the stack to usecases - the cases to use
public void compileDerivative(ExpressionProgram prog,
                              int myIndex,
                              ExpressionProgram deriv,
                              Variable wrt)
compileDerivative in interface ExpressionCommandprog - program containing the constantmyIndex - location of the constantderiv - the derivativewrt - variable with respect to
public int extent(ExpressionProgram prog,
                  int myIndex)
extent in interface ExpressionCommandprog - program containing the constantmyIndex - location of the constant
public boolean dependsOn(Variable x)
dependsOn in interface ExpressiondependsOn in interface ExpressionCommandx - variable to check if depends on
public void appendOutputString(ExpressionProgram prog,
                               int myIndex,
                               java.lang.StringBuffer buffer)
appendOutputString in interface ExpressionCommandprog - program containing the constantmyIndex - location of the constantbuffer - string to append
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||