Class State
java.lang.Object
edu.uky.cs.nil.tt.world.State
A state is an
assignment of values to each
variable in a story world.
State objects are unmodifiable. Calls to set(Assignment) create and
return a new state and do not modify the object on which they are called.
- Author:
- Stephen G. Ware
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value assigned to the given variable, or null if the variable does not exist in this state or is assigned a null value.Returns an unmodifiable list of assignments of a value to each variable in the state.getCode()Returns a string of1's and0's that uniquely represents this object among other objects of the same type in the same story world.Returns a human-readable natural language description of the object.inthashCode()set(Assignment assignment) Returns a new state object that is identical to this one, except with the variable in the given assignment set to the given value.protected StatesetDescription(String description) Returns a new state that is the same as this state, except this itsdescriptionis the given value.toString()
-
Constructor Details
-
State
Constructs a state that assigns default values to every variable in a story world.- Parameters:
world- the world whose variables will be assigned default values
-
-
Method Details
-
equals
-
hashCode
-
toString
-
getDescription
Description copied from interface:DescribedReturns a human-readable natural language description of the object.- Specified by:
getDescriptionin interfaceDescribed- Returns:
- a human-readable natural language description of the object
-
setDescription
Returns a new state that is the same as this state, except this itsdescriptionis the given value.- Parameters:
description- the description the new state should have- Returns:
- a state identical to this state, except with the given description
-
getCode
Description copied from interface:EncodedReturns a string of1's and0's that uniquely represents this object among other objects of the same type in the same story world. Every encoded object of the same type should return a string of the same length, even if it must be padded with0's. -
getAssignments
Returns an unmodifiable list of assignments of a value to each variable in the state.- Returns:
- an unmodifiable list of variable assignments
-
get
-
set
Returns a new state object that is identical to this one, except with the variable in the given assignment set to the given value.- Parameters:
assignment- an assignment the new state should contain- Returns:
- a new state the reflects the given assignment
-