Class Ending

All Implemented Interfaces:
Described, Encoded, Logical, Unique, Comparable<Ending>

public final class Ending extends SignedAsset implements Comparable<Ending>, Encoded
An ending is a signed asset that represents one of several possible ways a story can end.
Author:
Stephen G. Ware
  • Constructor Details

    • Ending

      public Ending(int id, Signature signature, String description, String code)
      Constructs a new ending.
      Parameters:
      id - the ending's unique ID number
      signature - the ending's unique signature
      description - the ending's description
      code - the ending's code
  • Method Details

    • compareTo

      public int compareTo(Ending other)
      Specified by:
      compareTo in interface Comparable<Ending>
    • setID

      protected Ending setID(int id)
      Description copied from class: Asset
      Returns a new asset that is the same as this asset, except that its ID number is the given value.
      Specified by:
      setID in class Asset
      Parameters:
      id - the ID number the new asset should have
      Returns:
      an asset identical to this asset, except with the given ID number
    • setSignature

      protected Ending setSignature(Signature signature)
      Description copied from class: SignedAsset
      Returns a new signed asset that is the same as this asset, except that its signature and name are the given value.
      Specified by:
      setSignature in class SignedAsset
      Parameters:
      signature - the signature and name the new asset should have
      Returns:
      a signed asset identical to this asset, except with the given signature and name
    • setDescription

      public Ending setDescription(String description)
      Description copied from class: Asset
      Returns a new asset that is the same as this asset, except that its description is the given value.
      Specified by:
      setDescription in class Asset
      Parameters:
      description - the description the new asset should have
      Returns:
      an asset identical to this asset, 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
    • setCode

      protected Ending setCode(String code)
      Returns a new ending that is the same as this ending, except this its code is the given value.
      Parameters:
      code - the code the new ending should have
      Returns:
      an ending identical to this ending, except with the given code
    • substitute

      public Ending 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
      Specified by:
      substitute in class SignedAsset
      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