Question: Code in java Create an enumeration called Pitch.java that represents the 12 different notes in an octave: Pitch CSHARP DSHARP FSHARP GSHARP ASHARP getOffset(): int

Code in java

Code in java Create an enumeration called Pitch.java that represents the 12

Create an enumeration called Pitch.java that represents the 12 different notes in an octave: Pitch CSHARP DSHARP FSHARP GSHARP ASHARP getOffset(): int toString(): String The enum class should have add two extra methods. The first, getOffset(), returns the offset shown in the table below; Pitch. A.getOffset() should return 0, and Pitch.C.getOffset() should return -9. Note || C | C | D D'EFF GTG'ALAB Value 0 1 2 3 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 Offset - 9 -8 -7 -6 -5 -4 -3 -2 -10 1 2 Figure 11: Table of Note values and offsets The toString() method should return the note in the format "C#". That is, use a "#" symbol instead of the word "SHARP" when you print out the note. For non-sharp notes, toString() returns the same as name(). You can add private attributes and constructors to the enumeration as you see fit to make imple- menting these two methods easier

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!