Module hw06

Class Note

java.lang.Object
provided.abcMusic.musicFW.Note
All Implemented Interfaces:
INote, IPhrase

public class Note extends Object implements INote
Basic class representing musical Notes. ---------------------------------------------- A playable note or rest.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Accidental (normally in {-1, 0, +1})
    private double
    Duration
    static String
    The ID value of this class
    private boolean
    Flag to override key signature
    private char
    Note name: {A, B, C, D, E, F, G, Z} (Z = rest)
    private int
    Octave value
  • Constructor Summary

    Constructors
    Constructor
    Description
    Note​(char name, int octave, int accidental, double duration, boolean isNatural)
    Constructor for the class
  • Method Summary

    Modifier and Type
    Method
    Description
    execute​(IPhraseVisitor algo, Object... params)
    Calls the Note.ID case of the visitor.
    int
    Accessor to get the value of the accidental
    double
    Accessor to get the note duraton
    boolean
    Accessor for isNatural flag
    char
    Accessor to get the name of the note
    int
    Accessor to get the octave
    void
    setAccidental​(int accidental)
    Accessor to set the accidental value
    void
    setDuration​(double duration)
    Accessor to set the note duration
    void
    setIsNatural​(boolean isNatural)
    Settor for isNatural flag.
    void
    setName​(char name)
    Accessor to set the name of the note
    void
    setOctave​(int octave)
    Accessor to set the octave of the note
    Returns a string representation of the Note

    Methods inherited from class java.lang.Object

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

    • ID

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

      private char name
      Note name: {A, B, C, D, E, F, G, Z} (Z = rest)
    • octave

      private int octave
      Octave value
    • accidental

      private int accidental
      Accidental (normally in {-1, 0, +1})
    • duration

      private double duration
      Duration
    • isNatural

      private boolean isNatural
      Flag to override key signature
  • Constructor Details

    • Note

      public Note(char name, int octave, int accidental, double duration, boolean isNatural)
      Constructor for the class
      Parameters:
      name - The name of the note
      octave - The octave of the note w.r.t. middle C. Zero = same octave as middle C.
      accidental - accidental setting sharp > 0, flat < 0
      duration - duration of note
      isNatural - flag to override key signature. True if note should be natural, overriding key signature.
  • Method Details

    • toString

      public String toString()
      Returns a string representation of the Note
      Overrides:
      toString in class Object
      Returns:
      "(name, octave, duration)"
    • execute

      public Object execute(IPhraseVisitor algo, Object... params)
      Calls the Note.ID case of the visitor.
      Specified by:
      execute in interface IPhrase
      Parameters:
      algo - The visitor to execute
      params - The input parameters supplied to the algo when its appropriate case is called.
      Returns:
      The return value from executing the appropriate case on the visitor.
    • setName

      public void setName(char name)
      Accessor to set the name of the note
      Parameters:
      name - - the name to set
    • getName

      public char getName()
      Accessor to get the name of the note
      Returns:
      the name
    • setOctave

      public void setOctave(int octave)
      Accessor to set the octave of the note
      Parameters:
      octave - - the octave to set
    • getOctave

      public int getOctave()
      Accessor to get the octave
      Returns:
      the octave
    • setAccidental

      public void setAccidental(int accidental)
      Accessor to set the accidental value
      Parameters:
      accidental - - the accidental to set
    • getAccidental

      public int getAccidental()
      Accessor to get the value of the accidental
      Returns:
      the accidental
    • setDuration

      public void setDuration(double duration)
      Accessor to set the note duration
      Parameters:
      duration - - the duration to set
    • getDuration

      public double getDuration()
      Accessor to get the note duraton
      Returns:
      the duration
    • getIsNatural

      public boolean getIsNatural()
      Accessor for isNatural flag
      Returns:
      isNatural flag setting
    • setIsNatural

      public void setIsNatural(boolean isNatural)
      Settor for isNatural flag. Accidentals will be set to zero if isNatural is true.
      Parameters:
      isNatural - New isNatural setting