Class Turn

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

public class Turn extends Object implements Described, Encoded
A turn is one participant in a session communicating their intentions for an action to the other participant.

There are four types of turns:

Author:
Stephen G. Ware
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The kind of turn being taken
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Action
    The action that this turn is relevant to
    final Role
    The role of the participant taking this turn
    final Turn.Type
    The kind of turn being taken
  • Constructor Summary

    Constructors
    Constructor
    Description
    Turn(Role role, Turn.Type type, Action action)
    Constructs a turn with no description and automatically computes its code.
    Turn(Role role, Turn.Type type, Action action, String description)
    Constructs a turn and automatically computes its code.
    Turn(Role role, World world)
    Constructs a pass turn for a given story world.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    Returns a human-readable natural language description of the object.
    setDescription(String description)
    Returns a new turn that is the same as this turn, except this its description is the given value.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • role

      public final Role role
      The role of the participant taking this turn
    • type

      public final Turn.Type type
      The kind of turn being taken
    • action

      public final Action action
      The action that this turn is relevant to
  • Constructor Details

    • Turn

      public Turn(Role role, Turn.Type type, Action action, String description)
      Constructs a turn and automatically computes its code.
      Parameters:
      role - the role of the participant taking this turn
      type - the kind of turn being taken
      action - the action relevant to this turn
      description - a natural language description of this turn
    • Turn

      public Turn(Role role, Turn.Type type, Action action)
      Constructs a turn with no description and automatically computes its code.
      Parameters:
      role - the role of the participant taking this turn
      type - the kind of turn being taken
      action - the action relevant to this turn
    • Turn

      public Turn(Role role, World world)
      Constructs a pass turn for a given story world.
      Parameters:
      role - the role who is passing
      world - the story world the session takes place in
  • Method Details

    • 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 Turn setDescription(String description)
      Returns a new turn that is the same as this turn, except this its description is the given value.
      Parameters:
      description - the description the new turn should have
      Returns:
      a turn identical to this turn, 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