Class Assignment

java.lang.Object
edu.uky.cs.nil.tt.world.Assignment
All Implemented Interfaces:
Described, Encoded, Logical

public class Assignment extends Object implements Described, Encoded, Logical
An assignment is a logical formula that assets that some variable in a story world has a value.
Author:
Stephen G. Ware
  • Field Details

    • variable

      public final Variable variable
      The variable that is being assigned a value
    • value

      public final Value value
      The value assigned to the variable
  • Constructor Details

    • Assignment

      public Assignment(Variable variable, Value value, String description)
      Constructs a new assignment from a variable, value, and description.
      Parameters:
      variable - the variable whose value is being assigned
      value - the value being assigned to the variable
      description - a natural language description of what it means for this variable to have this value
    • Assignment

      public Assignment(Variable variable, Value value)
      Constructs a new assignment from a variable and value with a blank description.
      Parameters:
      variable - the variable whose value is being assigned
      value - the value being assigned to the variable
  • Method Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDescription

      public String getDescription()
      Description copied from interface: Described
      Returns a human-readable natural language description of the object.
      Specified by:
      getDescription in interface Described
      Returns:
      a human-readable natural language description of the object
    • setDescription

      public Assignment setDescription(String description)
      Returns a new assignment that is the same as this assignment, except that its description is the given value.
      Parameters:
      description - the description the new assignment should have
      Returns:
      an assignment identical to this assignment, except with the given description
    • getCode

      public String getCode()
      Description copied from interface: Encoded
      Returns a string of 1's and 0'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 with 0's.
      Specified by:
      getCode in interface Encoded
      Returns:
      a string of 1's and 0's
    • substitute

      public Assignment substitute(Function<Object,Object> substitution)
      Description copied from interface: Logical
      Returns 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:
      substitute in interface Logical
      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