Module hw06

Class NESeqList

java.lang.Object
provided.abcMusic.musicFW.NESeqList
All Implemented Interfaces:
IPhrase, ISeqList

public class NESeqList extends Object implements ISeqList
A non-empty ("cons") sequence list. ---------------------------------------------- A non-empty ISeqList
  • Field Details

    • ID

      public static final String ID
      The ID value of this class
      See Also:
      Constant Field Values
    • _first

      private IPhrase _first
      The "first" of the list
    • _rest

      private ISeqList _rest
      The "rest" of the list
    • _toStringAlgo

      private static IPhraseVisitor _toStringAlgo
      toString algo for rest, the recursive helper function of the ToString algo.
  • Constructor Details

    • NESeqList

      public NESeqList(IPhrase first, ISeqList rest)
      Cons an IPhrase to a Sequence List.
      Parameters:
      first - The first element of the sequence
      rest - The rest of the sequence
  • Method Details

    • getFirst

      public IPhrase getFirst()
      Accessor method for the first element
      Returns:
      the IPhrase that is the first element of the sequence list
    • getRest

      public ISeqList getRest()
      Accessor method for the rest of the lsit
      Returns:
      the rest of the sequence list
    • execute

      public Object execute(IPhraseVisitor algo, Object... params)
      Calls the NESeqList.ID case of the visitor.
      Specified by:
      execute in interface IPhrase
      Parameters:
      algo - The visitor that is being used
      params - vararg input parameters for the visitor.
      Returns:
      the result of running the visitor on this host.
    • setToStringAlgo

      public static void setToStringAlgo(IPhraseVisitor stringAlgo)
      Setter for the _toStringAlgo helper. This non-typical method is provided solely for the purpose of enabling the student to install their toStringAlgo into the read-only provided code.
      Parameters:
      stringAlgo - The helper algo to use.
    • getToStringAlgo

      static IPhraseVisitor getToStringAlgo()
      Getter for the _toStringAlgo helper. Only for use internally inside this package so ToggleDecoratorSeqList and FineToggleDecoratorSeqList can use the same visitor.
      Returns:
      the toStringAlgo helper visitor
    • toString

      public String toString()
      Run a visitor over the list to convert it to a String. Delegates to the rest of the list using the helper algo, with the accumulator (params[0]) set to "{"+_first.toString().
      Overrides:
      toString in class Object
      Returns:
      "{a, b, c, d}"