Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the UML diagram below for the specific directions to create fields and metho

ID: 3758616 • Letter: U

Question

Use the UML diagram below for the specific directions to create fields and methods for the SongBird class. Create a driver or client class named LabAssign5 which uses the SongBird class.

SongBird

- myBird: Finch

+ SongBird()

- playNote(char note) : boolean

+ parseSong(String song) : void

+ stopSong( ) : void

The playNote(char note) method takes a character as input, plays the note, and either returns true, if the note is valid, or false if invalid. Acceptable characters are A,a,B,b,C,c,D,d,E,e,F,f,G, and g. This method will use the Finch’s playTone( ) method to generate the correct musical note. Use playTone( ) which takes two arguments – frequency, and duration. For duration, you can use 500 ms for lower case characters and 1000 ms for upper case characters (so upper case characters are long notes and lower case are short notes). For frequency, use the following mapping of characters to frequencies:

Aa – 440

Bb – 494

Cc – 262

Dd – 294

Ee – 330

Ff – 349

Gg - 392

When a note is played, you should also light the Finch’s beak; each note of a different frequency should have a unique color, though notes with the same frequency but different durations (like ‘A’ and ‘a’) can have the same color.

A second method, parseSong(String song ) is needed for accepting input for the notes of the song. This method accepts a String as an argument which is a series of notes. Inside the method is a call to the playNote( ) method parsing each character of the input String. If there is a bad note in the argument String, the Finch should stop and announce it’s stopping.

The stopSong( ) method calls the Finch’s quit( ) and System.exit(0) methods.

Write the driver class, LabAssign4 and create an instance of the SongBird class. Allow for multiple inputs.

Here are some songs you might recognize:

ccggaaGffeeddCggffeeDggffeeDccggaaGffeeddC

bagabbbaaabdDbagabbbbaabaG

CCCdEedefG

cdeccdecefGefG

SongBird

- myBird: Finch

+ SongBird()

- playNote(char note) : boolean

+ parseSong(String song) : void

+ stopSong( ) : void

Explanation / Answer

CODE :