JSHOP2
Class TermNumber

java.lang.Object
  extended by JSHOP2.CompileTimeObject
      extended by JSHOP2.Term
          extended by JSHOP2.TermNumber

public class TermNumber
extends Term

Each numerical term both at compile time and at run time, is an instance of this class.

Version:
1.0.3
Author:
Okhtay Ilghami, http://www.cs.umd.edu/~okhtay

Field Summary
private  double number
          The value of the numerical term.
 
Fields inherited from class JSHOP2.CompileTimeObject
endl
 
Constructor Summary
TermNumber(double numberIn)
          To initialize this numerical term.
 
Method Summary
 Term bind(Term[] binding)
          Since this term is a numerical term, binding will not change it, therefore, simply this numerical term itself is returned.
 boolean equals(Term t)
          Whether or not another term is equivalent to this numerical term.
 boolean findUnifier(Term t, Term[] binding)
          Find a unifier between this numerical term and another given term.
 double getNumber()
          To get the value of this numerical term.
 boolean isGround()
          This function always returns true because a numerical term is always ground by definition.
 java.lang.String toCode()
          This function produces Java code to create this numerical.
 java.lang.String toString()
          This function returns the String representation of the value of this numerical term.
 
Methods inherited from class JSHOP2.Term
isNil, merge, merge, print
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

number

private double number
The value of the numerical term.

Constructor Detail

TermNumber

public TermNumber(double numberIn)
To initialize this numerical term.

Parameters:
numberIn - the value this numerical term is set to have.
Method Detail

bind

public Term bind(Term[] binding)
Since this term is a numerical term, binding will not change it, therefore, simply this numerical term itself is returned.

Specified by:
bind in class Term
Parameters:
binding - an array of terms, indexed by the integers associated with variable symbols.
Returns:
the result of binding.

equals

public boolean equals(Term t)
Whether or not another term is equivalent to this numerical term.

Specified by:
equals in class Term
Parameters:
t - the term being compared to this term.
Returns:
true if the two terms are equal, false otherwise.

findUnifier

public boolean findUnifier(Term t,
                           Term[] binding)
Find a unifier between this numerical term and another given term. Since this term is a number, this boils down to whether or not the other given term is equal to this one.

Specified by:
findUnifier in class Term
Parameters:
t - the term with which we are finding a unifier.
binding - the unifier to be returned.
Returns:
false if the two terms can not be unified, true otherwise.

getNumber

public double getNumber()
To get the value of this numerical term.

Returns:
the value of this numerical term.

isGround

public boolean isGround()
This function always returns true because a numerical term is always ground by definition.

Specified by:
isGround in class Term
Returns:
true if this term is ground, false otherwise.

toCode

public java.lang.String toCode()
This function produces Java code to create this numerical.

Specified by:
toCode in class CompileTimeObject
Returns:
the produced code as a String.

toString

public java.lang.String toString()
This function returns the String representation of the value of this numerical term.

Specified by:
toString in class Term
Returns:
the printable String that shows the value of this term.