Class Constant
java.lang.Object
edu.uky.cs.nil.tt.world.Constant
- All Implemented Interfaces:
Expression, Logical, Value
A constant is a
logical value that always exists in all story worlds, such a the Boolean concepts of True and False, numbers,
and so on.- Author:
- Stephen G. Ware
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstant(boolean value) Constructs a new constant that represents a Boolean value.Constant(float value) Constructs a new constant that represents a decimal number.Constant(int value) Constructs a new constant that represents an integer.Constructs a new constant equivalent toNULL. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()substitute(Function<Object, Object> substitution) Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution.booleanIf this value represents a Boolean, this method convert it into a Javaboolean; all other values are converted tofalse.doubletoNumber()If this value represents a number, this method convert it into a Javadouble; all other values are converted toDouble.NaN.toString()
-
Field Details
-
NULL
A constant representing nothing or the absence of a value -
TRUE
A constant representing Boolean true -
FALSE
A constant representing Boolean false -
value
The Java object associated with this constant
-
-
Constructor Details
-
Constant
-
Constant
public Constant(boolean value) Constructs a new constant that represents a Boolean value.- Parameters:
value- the boolean value
-
Constant
public Constant(int value) Constructs a new constant that represents an integer.- Parameters:
value- the integer value
-
Constant
public Constant(float value) Constructs a new constant that represents a decimal number.- Parameters:
value- the decimal value
-
-
Method Details
-
equals
-
hashCode
-
toString
-
substitute
Description copied from interface:LogicalReturns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution. A substitution defines how some logical formula (the input to the function) should be replaced with a different formula (the output of the function).- Specified by:
substitutein interfaceExpression- Specified by:
substitutein interfaceLogical- Specified by:
substitutein interfaceValue- Parameters:
substitution- a function which maps logical formula that should be replaced to the formula they should be replaced with- Returns:
- an identical object, except that its logical formula have been replaced according to the substitution
-
toBoolean
public boolean toBoolean()Description copied from interface:ValueIf this value represents a Boolean, this method convert it into a Javaboolean; all other values are converted tofalse. -
toNumber
public double toNumber()Description copied from interface:ValueIf this value represents a number, this method convert it into a Javadouble; all other values are converted toDouble.NaN.
-