Homework Solution: Hi, can i get help modifying and completing the constructors and methods on thi code. Thanks…

    Hi, can i get help modifying and completing the constructors and methods on thi code. Thanks package edu.uwm.cs351; /** * The Immutable Class Note. */ public class Note { /** Static Constants */ public static final int DEFAULT_INTENSITY = 50; public static final int REST_PITCH = 128; // First illegal pitch, used for rests. private static final int PITCHES_PER_OCTAVE = 12; private static final String[] NOTE_LETTERS = {"c","c#","d","d#","e","f","f#","g","g#","a","a#","b"}; private static final double MIN_DURATION = 1.0/64, // One sixty-fourth MAX_DURATION = 8.0; // Eight whole notes /** Fields (Immutable) */ private final String pitch="f6"; private final int midiValue=42; private final double duration=0.02; /** * Instantiates a new note based on a string denoting note letter and octave. * * @param pitch the pitch (e.g. "f6") * @param duration the duration * @throws NullPointerException if pitch is null * @throws IllegalArgumentException if: * 1. The pitch parameter is malformed or out of range. * 2. The duration parameter is out of range. */ public Note(String pitch, double duration) { // TODO // Recommended: First implement toMidi(String). if(pitch == null) { throw new NullPointerException(); } if(duration < MIN_DURATION || duration > MAX_DURATION || Arrays.binarySearch(NOTE_LETTERS, pitch) == -1){ throw new IllegalArgumentException(); } } /** * Instantiates a new note based on MIDI value. * * @param midiValue the MIDI value (e.g. 68) * @param duration the duration * @throws IllegalArgumentException if: * 1. The MIDI pitch parameter is out of range. * 2. The duration parameter is out of range. */ public Note(int midiValue, double duration) { // TODO // Recommended: First implement toPitch(int). } /** * Instantiates a new note from a String matching the format of Note's toString() method. * * @param note the string representation * * @throws IndexOutOfBoundsException if parameter isn't in correct format * @throws NumberFormatException if duration representation cannot be parsed as double * @throws IllegalArgumentException if the elements in the format are not permitted. */ public Note(String note) { this(note.split(" x ")[0], Double.parseDouble(note.split(" x ")[1])); } /** * Converts a pitch string to a MIDI value. * The pitch "rest" should return {@link #REST_PITCH}. * * @param pitch the pitch to convert * @throws NullPointerException if pitch is null * @throws IllegalArgumentException is the String is not a legal pitch * @return the MIDI value */ public static int toMidi(String pitch) { // TODO return -1; } /** * Converts a MIDI value to a pitch string. * The MIDI value 128 should return "rest". * * @param midiValue the MIDI value to convert * @throws IllegalArgumentException if the MIDI value is outside of legal range * @return the pitch string */ public static String toPitch(int midiValue) { // TODO return null; } /** * Gets the pitch string of this note. * * @return the pitch */ public String getPitch() { return pitch; } /** * Gets the MIDI value of this note. * * @return the MIDI value */ public int getMidiPitch() { return midiValue; } /** * Gets the duration of this note. * * @return the duration */ public double getDuration() { return duration; } /** * Returns a new note with the same pitch, but with its duration multiplied by the parameter. * * @param factor the amount to scale by * @throws IllegalArgumentException if resultant duration is outside of valid range * @return the stretched note */ public Note stretch(double factor) { // TODO return null; } /** * Returns a (new) note with the same duration, but transposed by the given interval. * * @param interval the interval to transpose by * @throws IllegalArgumentException if note is transposed beyond valid bounds [c0, g10] * @return the transposed note */ public Note transpose(int interval) { // TODO return null; } /** * Returns a string representation of this Note. * It should follow the format found in songs/InMyLife.song, namely: * For a Note with pitch "g#4" and duration 1.0625 -> "g#4 x 1.0625" * NB1: Identical spacing and format are important! * NB2: For a "rest" note, the same format must be used (including duration). * * @return the string representation */ @Override public String toString() { // TODO return null; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { // TODO: Return equal if the argument is a Note and the midiValue and duration are equal return false; } @Override public int hashCode() { // TODO: Compute hash using pieces. (Don't take hash code of strings.) return -1; } }

    Expert Answer

     
    package edu.uwm.cs351; /** * The Immutable Class Note.

    Hi, can i attain acceleration modifying and completing the constructors and systems on thi decree. Thanks

    package edu.uwm.cs351;

    /**

    * The Immutable Adjust Still n ess.

    */

    public adjust Still n ess {

    /** Static Constants */

    public static conclusive int DEFAULT_INTENSITY = 50;

    public static conclusive int REST_PITCH = 128; // First illicit cast, used ce rests.

    private static conclusive int PITCHES_PER_OCTAVE = 12;

    private static conclusive String[] NOTE_LETTERS = {“c”,”c#”,”d”,”d#”,”e”,”f”,”f#”,”g”,”g#”,”a”,”a#”,”b”};

    private static conclusive embrace MIN_DURATION = 1.0/64, // One sixty-fourth

    MAX_DURATION = 8.0; // Eight undiminished still n esss

    /** Fields (Immutable) */

    private conclusive String cast=”f6″;

    private conclusive int midiValue=42;

    private conclusive embrace protraction=0.02;

    /**

    * Instantiates a odd still n ess established on a string denoting still n ess communication and octave.

    *

    * @param cast the cast (e.g. “f6″)

    * @param protraction the protraction

    * @throws TriflingPointerException if cast is trifling

    * @throws IllicitArgumentException if:

    * 1. The cast parameter is malformed or quenched of stroll.

    * 2. The protraction parameter is quenched of stroll.

    */

    public Still n ess(String cast, embrace protraction) {

    // TODO

    // Recommended: First utensil toMidi(String).

    if(cast == trifling) {

    throw odd TriflingPointerException();

    }

    if(protraction < MIN_DURATION || protraction > MAX_DURATION || Arrays.binarySearch(NOTE_LETTERS, cast) == -1){

    throw odd IllicitArgumentException();

    }

    }

    /**

    * Instantiates a odd still n ess established on MIDI appraise.

    *

    * @param midiAppraise the MIDI appraise (e.g. 68)

    * @param protraction the protraction

    * @throws IllicitArgumentException if:

    * 1. The MIDI cast parameter is quenched of stroll.

    * 2. The protraction parameter is quenched of stroll.

    */

    public Still n ess(int midiValue, embrace protraction) {

    // TODO

    // Recommended: First utensil toPitch(int).

    }

    /**

    * Instantiates a odd still n ess from a String matching the cemat of Still n ess’s toString() system.

    *

    * @param still n ess the string justice

    *

    * @throws IndexOutOfBoundsException if parameter isn’t in chasten cemat

    * @throws NumberFormatException if protraction justice cannot attributable attributable attributable attributable be parsed as embrace

    * @throws IllicitArgumentException if the elements in the cemat are not attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable unreserved.

    */

    public Still n ess(String still n ess) {

    this(note.split(” x “)[0], Embrace.parseDouble(note.split(” x “)[1]));

    }

    /**

    * Converts a cast string to a MIDI appraise.

    * The cast “rest” should recompense {@link #REST_PITCH}.

    *

    * @param cast the cast to convert

    * @throws TriflingPointerException if cast is trifling

    * @throws IllicitArgumentException is the String is not attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable a constitutional cast

    * @recompense the MIDI appraise

    */

    public static int toMidi(String cast) {

    // TODO

    recompense -1;

    }

    /**

    * Converts a MIDI appraise to a cast string.

    * The MIDI appraise 128 should recompense “rest”.

    *

    * @param midiAppraise the MIDI appraise to convert

    * @throws IllicitArgumentException if the MIDI appraise is quenchedside of constitutional stroll

    * @recompense the cast string

    */

    public static String toPitch(int midiValue) {

    // TODO

    recompense trifling;

    }

    /**

    * Attains the cast string of this still n ess.

    *

    * @recompense the cast

    */

    public String attainPitch() { recompense cast; }

    /**

    * Attains the MIDI appraise of this still n ess.

    *

    * @recompense the MIDI appraise

    */

    public int attainMidiPitch() { recompense midiValue; }

    /**

    * Attains the protraction of this still n ess.

    *

    * @recompense the protraction

    */

    public embrace attainDuration() { recompense protraction; }

    /**

    * Recompenses a odd still n ess with the corresponding cast, save with its protraction multiplied by the parameter.

    *

    * @param content the total to layer by

    * @throws IllicitArgumentException if unimportant protraction is quenchedside of available stroll

    * @recompense the smart still n ess

    */

    public Still n ess reach(embrace content) {

    // TODO

    recompense trifling;

    }

    /**

    * Recompenses a (new) still n ess with the corresponding protraction, save transferd by the abandoned period.

    *

    * @param period the period to transfer by

    * @throws IllicitArgumentException if still n ess is transferd more available boundary [c0, g10]

    * @recompense the transferd still n ess

    */

    public Still n ess transfer(int period) {

    // TODO

    recompense trifling;

    }

    /**

    * Recompenses a string justice of this Still n ess.

    * It should prosper the cemat set in epics/InMyLife.song, namely:

    * Ce a Still n ess with cast “g#4” and protraction 1.0625 -> “g#4 x 1.0625”

    * NB1: Identical spacing and cemat are important!

    * NB2: Ce a “rest” still n ess, the corresponding cemat must be used (including protraction).

    *

    * @recompense the string justice

    */

    @Override

    public String toString() {

    // TODO

    recompense trifling;

    }

    /* (non-Javadoc)

    * @see java.lang.Object#equals(java.lang.Object)

    */

    @Override

    public boolean similars(Object o) {

    // TODO: Recompense similar if the discussion is a Still n ess and the midiAppraise and protraction are similar

    recompense false;

    }

    @Override

    public int hashCode() {

    // TODO: Compute hash using pieces. (Don’t choose hash decree of strings.)

    recompense -1;

    }

    }

    Expert Repartee

     

    package edu.uwm.cs351;

    /**

    * The Immutable Adjust Still n ess.

    */

    public adjust Still n ess {

    /** Static Constants */

    public static conclusive int DEFAULT_INTENSITY = 50;

    public static conclusive int REST_PITCH = 128; // First illicit cast, used ce rests.

    private static conclusive int PITCHES_PER_OCTAVE = 12;

    private static conclusive String[] NOTE_LETTERS = {“c”,”c#”,”d”,”d#”,”e”,”f”,”f#”,”g”,”g#”,”a”,”a#”,”b”};

    private static conclusive embrace MIN_DURATION = 1.0/64, // One sixty-fourth

    MAX_DURATION = 8.0; // Eight undiminished still n esss

    /** Fields (Immutable) */

    private conclusive String cast=”f6″;

    private conclusive int midiValue=42;

    private conclusive embrace protraction=0.02;

    /**

    * Instantiates a odd still n ess established on a string denoting still n ess communication and octave.

    *

    * @param cast the cast (e.g. “f6″)

    * @param protraction the protraction

    * @throws TriflingPointerException if cast is trifling

    * @throws IllicitArgumentException if:

    * 1. The cast parameter is malformed or quenched of stroll.

    * 2. The protraction parameter is quenched of stroll.

    */

    public Still n ess(String cast, embrace protraction) {

    // TODO

    // Recommended: First utensil toMidi(String).

    if(cast == trifling) {

    throw odd TriflingPointerException();

    }

    if(protraction < MIN_DURATION || protraction > MAX_DURATION || Arrays.binarySearch(NOTE_LETTERS, cast) == -1){

    throw odd IllicitArgumentException();

    }

    }

    /**

    * Instantiates a odd still n ess established on MIDI appraise.

    *

    * @param midiAppraise the MIDI appraise (e.g. 68)

    * @param protraction the protraction

    * @throws IllicitArgumentException if:

    * 1. The MIDI cast parameter is quenched of stroll.

    * 2. The protraction parameter is quenched of stroll.

    */

    public Still n ess(int midiValue, embrace protraction) {

    // TODO

    // Recommended: First utensil toPitch(int).

    }

    /**

    * Instantiates a odd still n ess from a String matching the cemat of Still n ess’s toString() system.

    *

    * @param still n ess the string justice

    *

    * @throws IndexOutOfBoundsException if parameter isn’t in chasten cemat

    * @throws NumberFormatException if protraction justice cannot attributable attributable attributable attributable be parsed as embrace

    * @throws IllicitArgumentException if the elements in the cemat are not attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable unreserved.

    */

    public Still n ess(String still n ess) {

    this(note.split(” x “)[0], Embrace.parseDouble(note.split(” x “)[1]));

    }

    /**

    * Converts a cast string to a MIDI appraise.

    * The cast “rest” should recompense {@link #REST_PITCH}.

    *

    * @param cast the cast to convert

    * @throws TriflingPointerException if cast is trifling

    * @throws IllicitArgumentException is the String is not attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable attributable a constitutional cast

    * @recompense the MIDI appraise

    */

    public static int toMidi(String cast) {

    // TODO

    recompense -1;

    }

    /**

    * Converts a MIDI appraise to a cast string.

    * The MIDI appraise 128 should recompense “rest”.

    *

    * @param midiAppraise the MIDI appraise to convert

    * @throws IllicitArgumentException if the MIDI appraise is quenchedside of constitutional stroll

    * @recompense the cast string

    */

    public static String toPitch(int midiValue) {

    // TODO

    recompense trifling;

    }

    /**

    * Attains the cast string of this still n ess.

    *

    * @recompense the cast

    */

    public String attainPitch() { recompense cast; }

    /**

    * Attains the MIDI appraise of this still n ess.

    *

    * @recompense the MIDI appraise

    */

    public int attainMidiPitch() { recompense midiValue; }

    /**

    * Attains the protraction of this still n ess.

    *

    * @recompense the protraction

    */

    public embrace attainDuration() { recompense protraction; }

    /**

    * Recompenses a odd still n ess with the corresponding cast, save with its protraction multiplied by the parameter.

    *

    * @param content the total to layer by

    * @throws IllicitArgumentException if unimportant protraction is quenchedside of available stroll

    * @recompense the smart still n ess

    */

    public Still n ess reach(embrace content) {

    // TODO

    recompense trifling;

    }

    /**

    * Recompenses a (new) still n ess with the corresponding protraction, save transferd by the abandoned period.

    *

    * @param period the period to transfer by

    * @throws IllicitArgumentException if still n ess is transferd more available boundary [c0, g10]

    * @recompense the transferd still n ess

    */

    public Still n ess transfer(int period) {

    // TODO

    recompense trifling;

    }

    /**

    * Recompenses a string justice of this Still n ess.

    * It should prosper the cemat set in epics/InMyLife.song, namely:

    * Ce a Still n ess with cast “g#4” and protraction 1.0625 -> “g#4 x 1.0625”

    * NB1: Identical spacing and cemat are important!

    * NB2: Ce a “rest” still n ess, the corresponding cemat must be used (including protraction).

    *

    * @recompense the string justice

    */

    @Override

    public String toString() {

    // TODO

    recompense trifling;

    }

    /* (non-Javadoc)

    * @see java.lang.Object#equals(java.lang.Object)

    */

    @Override

    public boolean similars(Object o) {

    // TODO: Recompense similar if the discussion is a Still n ess and the midiAppraise and protraction are similar

    recompense false;

    }

    @Override

    public int hashCode() {

    // TODO: Compute hash using pieces. (Don’t choose hash decree of strings.)

    recompense -1;

    }

    }