SlideShare a Scribd company logo
1 of 4
Download to read offline
Instructions This project focuses on queues and stacks. Following is the list of files that you need
for this project. DO NOT CHANGE ANYTHING IN THESE FILES. NOT EVEN A SINGLE LINE! -
StdAudio.java - Pitchjava - Accidentaljava - Note.java - Node.java - MelodyMainjava - Melody.java
You will add all of your methods to MelodyQueue.javaYour job is to complete the class that
represent a song: this class is called MelodyQueue. A song is comprised of a series of notes. It
may have repeated sections. As we don't like to have any redundancy, we will only store one copy
of a repeated chunk of notes. Music is usually printed like the example above. The notes are a
series of dots. Their position in relation to the lines determines their pitch and their tops and color,
among other things, determine their length. Since it would be difficult for us to read input in this
style, we will instead read input from a text file. An example input file is shown below: Each line in
it represents a single note. The first number describes the length of the note in seconds. The letter
that follows describes the pitch of the note, using the standard set of letters (AG) or R if the note is
a rest. For notes other than rests, the third item on the line is the octave that the note is in and the
following is the note's accidental value. The final piece of information for all notes is true if the note
is the start or stop of a repeated section and false otherwise. You will implement several methods
in the MelodyQueue class which will allow you to use MelodyMain to play your song with mp3
player like functionality. Your melody will be able to play as well as append another melody to
itself, reverse and have the it's tempo changed.You will add methods to the class:
MelodyQueue.java. You must use Java's Stack and Quetie from java.util. You must use them as
stacks and queues; you may NOT USE anything else that we have not discussed in the class such
as: iterators, iterables or anything of that sort. Your class must have the constructorsimethods
below. It must be possible to call the methods multiple times in any order and get the correct
results each time. Your MelodyQueue class will use a queue to store the notes in the song (all
quepes have pointer to the back and to the front). Bat unless otherwise specified, you may not
create any other auxiliary data structures (such as arrays, lists, stacks, quetes) to help you solve
any method below.MelodyQueue . java (for you to implement): public MelodyQueue () Constructor
with no parameters public void enqueue (Object item) Adds item to the back of the queue. Make
sure to cover the case that queue is null. public Object dequeue () Removes and returns item from
the front of queve. If the queue is null print a message that queve is null. public Boolean isEmpty ()
Checks if queue is empty. public double duration () Returns duration/time of queue. In other
words, it returns the total length of the song in seconds. If the song includes a repeated section the
length should include that repeated section twice. For example, the sample file shown on previous
page have length 3.6. public double timeRepeat () This is an auxiliary method that you will call in
duration method. The job of this method is to find the duration of repeated sectionsReturns the
size of the queve public String makestring() Returns String version of the notes in the queve. In
other words, it returns a String containing information about each note. Each note should be on its
own line similar to example on page 2. Your String should reflect the changes that have been
made to the song by calling other methods. public void tempochange (double tempo) Changes the
tempo of each note to be tempo percent of what it formerly was. Passing a tempo of 1.0 will make
the tempo stay the same. Tempo of 2.0 will make each note twice as long, so it will be slower.
Tempo of 0.5 will make each note half as long (make it faster). Keep in mind that when the tempo
changes the length of the song also changes. public void playRepeat() Again, this is an auxiliary
method. You will use it in play method. The job of this method is to play the repeated sections.
public void appendMelody (MelodyQueue other) Adds one melody at the end of another one. In
other words, it adds all notes from the other song (input parameter) to the end of this song. For
example, if this song is A,F,G,B and the other song is F, C, D, your method should change this
song to be A, F, G, B, F, C, D. The other song should be unchanged after the call.public
MelodyQueue reverseMelody () Reverses the order of the notes of a song. This method reverses
the order of notes in the song, so that future calls to the play methods will play the notes in the
opposite of the order they were in before reverse was called. For example, a song containing
notes A, F, G, then B would become B, G, F, A. You must use a temporary Stack to help you solve
this problem. public void play () Plays the song. Must call the playRepeat method. This method
plays the song by calling each note's play method. The notes should be played from the beginning
of the queue to the end unless there are notes that are marked as being the beginning or end of a
repeated section. When the first note that is a beginning or end of a repeated section is found you
should create a second queue. You should then get notes from the original queue until you see
another marked as being the beginning or end of a repeat.As you get these notes you should play
them and then place them back in both queues. Once you hit a second marked as beginning or
end of a repeat you should play everything in your secondary queue and then retum to playing
from the main queue. It should be possible to call this method multinle times and get the same
result. B The yellow blocks represent notes with start or end of a repeat set to true. They and the
other notes in between them should be moved to a separate queue when played so that they can
be repeated.Note Class and Melody Class (provided): You are provided with a class named Note
class that your MelodyQueue use. A Note object represents a single musical note that will form
part of a melody. It keeps track of the length (duration) of the note in seconds, the note's pitch (A-
G, or R if the note is a rest), the octave, and the accidental (sharp, natural or flat). Each Note
object also uses keeps track of whether it is the first or last note of a repeated section of the
melody. The Melody class is just an Interface that will use the methods you created in your
MelodyQueve class. The Note class provides the following constructors and methods that you
should use in yourYou can look at the contents of the provided Notejava to answer any further
questions about how it wotks. Development Strategy and Hints: 1 suggest the following
development strategy for solving this project: 1. Add all of the describe methods to the
MelodyQueve class. Leave every method's body blank: if necessary, return a "dummy" value like
null or 0 . Get your code to run in the MelodyMain program, though the output will be incorrect. 2.
Implement the constructor, and the makeString methods: 3. Implement the deration and
changeTempo methods. You can check the results of the changeTempo method by reading in one
of the sample files, calling changeTempo and then calling the makestring method and cliecking
your output matches what you expected. 4. Complete the reverse and append methods. 5. Write
an initial version of play0 that assumes there are no repeating sections. 6. Add the play0) code
that looks for repeated sections and plays them twice, as described previously. You can test the
outpot of your program by running it on various inputs in the MelodyMain client. Other blats? Take
a look at the Node class. For the project 2, you worked with similar Node class but here the one
variable of the Node class is different: private cbject item? private Node nexti5. Wneramanat
verstouror phyonuaratssumes utre are io repeaimg seculous, 6. Add the play() code that looks for
repeated sections and plays them twice, as described previously. You can test the output of your
program by running it on various inputs in the MelodyMain client. Other hints: Take a look at the
Node class. For the project 2, you worked with similar Node class but here the one variable of the
Node class is different: private Object item; private Node next; For this project the item that one
Node will be holding is a Note with all its features (Pitch. duration...). We have a queve of nodes
where each Node holds a Note. You can check read method in MelodyMainjava to see how the
queue is populated with the Notes. In other words, how the song is created! Next question is how
we can play the song. For that, you don't have to do anything because in class Note the method
play is added. You just have to use it: To play the notes int the queue, I can traverse the queue
from front to back (the provided references for the queve). Remember this queue contains Nodes.
To access to the content of a Note that is saved in a Node, we have to do the following: (let's refer
to the Node as current): ( (Note) current.getrtem( ()) -play () ; We need to do the typecasting to
convert the Node to a Note, othervise we receive an error. Similarly in any other methods of the
MelodyQueue, whenever you need to get access to the Note inside a Node, you must do this
typecasting.II When the progran starts, type load and enter the name of the file you want to play II
You can then type play to hear it or any of the other comands to test your Melody's II other
functionality.private static void intro() { Systen.out.println("Melcone to MelodyMain. Type the word
in the left colum to do the action on the right"); Systen.out.printlin("load : load a new input file");
Systen.out.println("save : output to a file"); Systee. out.println("print : prints the contents of the last
loaded song"); System.out.printin("play : play the last loaded song"); System.out.println("reverse :
reverse the last loaded song"); System.out.println("duration : print out the length of the last loaded
song in seconds"); System.out.println("tempo : change the speed by a percentage");
System.out.printlin("append : appends notes from a second melody to the loaded one");
System.out.println("quit : exit the program"); } II Checks to eake sure the file exists. Prompts the
user for a new file until they II input a valid one. Returns a file that exists. Renember that the file
should be in the II sane project folder. public static File checkFile(String name, Scanner console) f
I File file = new File(name); while (Ifile.exists()) { System.out.print("Invalid file. File name? "); file=
new File( console.next ()); ). 3 II Returns a Melodyqueue filled with the notes specified in the
provided II Scanner. The notes will appear in the same order in the Melodyqueue II as they did in
the file. public static MelodyQueve read (Scanner input) f Melodyqueue song = new
Melodyqueve();lic class Note { private Pitch note; private double duration; private int octave;
private Accidental accidental; private boolean repeat; I/ pre : duration > and octave =1, //otherwise
throws an IllegalArgumentException II constructs a note with the provided duration, pitch, octave,
accidental and repeat settings. public Mote(double duration, Pitch note, int octave, Accidental
accidental, boolean repeat) { if(duration <= octave < octave >10){ throw new
IllegalArgumentException(); 3 this. note = note; this.duration = duration; this octave = octave; this .
accidental = accidental this .repeat = repeat; 3 II pre : duration >, otherwise throws an
IllegalArgumentException II constructs a note with the passed in duration, pitch and repeat
settings. public Mote(double duration, Pitch note, boolean repeat) { this(duration, note, ,
Accidental.MATURAL, repeat); 3 II returns the length of the note in secondsII constructs a note
with the passed in duration, pitch and repeat settings. public Mote(double duration, Pitch note,
boolean repeat) { this(duration, note, 0 , Accidental.MATURAL, repeat); } II returns the length of
the note in seconds public double getDuration() { return duration; } II returns the Accidental value
of the note public Accidental getAccidental() { return accidental; } II returns the octave of the note
public int getoctave() { return octave; } II returns the pitch of the note (A - G or R of it is a rest)
public Pitch getpitch() { return note; 3 II pre : d must be greater than , otherwise an
IllegalArgumentException is thrown II sets the duration of the note to be the given time public void
setDuration(double d) { if (d<=){ throw new IllegalArgumentException(); pre : d must be greater
than , otherwise an IllegalArgumentException is thrown II sets the duration of the note to be the
given time public void setDuration(double d) { if (d<=){ throw new IllegalArgumentException();
duration =d; I/ sets the accidental of the note to be the given accidental public void
setAccidental(Accidental a) { accidental =a } // pre : octave must be greater than 0 and less than
10, II otherwise an IllegalArgumentException is thrown II sets the octave of the note to be the
passed in octave public void set0ctave(int octave) { if(octave <0 octave >10 ) { throw new
IllegalArgumentException(); } this octave = octave; 3 II sets the pitch of the note to be the passed
in pitch public void setPitch(Pitch pitch) { note = pitch; }I/ sets the pitch of the note to be the
passed in pitch public void setpitch(Pitch pitch) { note = pitch; I/ sets the repeat of the note to be
the passed in repeat public void setRepeat(boolean repeat) { this. repeat = repeat; } II returns true
if the note is the beginning or ending note in a repeated section, II false otherwise public boolean
isRepeat() { } II plays the sound this note represents public void play() { StdAudio.play(duration,
note, octave, accidental); II Otherwise returns a string in the format: public String tostring() { 4
SHARP true" and "1.5 R true". if(note.equals(Pitch. R )) { } else {I/ plays the sound this note
represents public void play() { } StdAudio.play(duration, note, octave, accidental); II otherwise
returns a string in the format: II For example "2.3 A 4 SHARP true" and "1.5 R true". public String
tostring() { if(note.equals(Pitch.R)) { return duration ++ note ++ + + repeat; } else { 3 return
duration +"+ note +"+ octave +" " + accidental +"=+ repeat; }public class MelodyQueve { private
Node front; private Node back; //Add all of your methods to this class. DO NOT CHAVGE ANY
OTHER CLASSESIIII public MelodyQueve() front = null; back = null; } public void enqueve (Object
item){ 33

More Related Content

Similar to Instructions This project focuses on queues and stacks Foll.pdf

BeepComp - Chiptune Creator - User's Guide (v0.2.2)
BeepComp - Chiptune Creator - User's Guide (v0.2.2)BeepComp - Chiptune Creator - User's Guide (v0.2.2)
BeepComp - Chiptune Creator - User's Guide (v0.2.2)Hiro Morozumi
 
91718032 tutorial-hidrogen
91718032 tutorial-hidrogen91718032 tutorial-hidrogen
91718032 tutorial-hidrogenhomeworkping4
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
 
Introduction to writing algorithms
Introduction to writing algorithmsIntroduction to writing algorithms
Introduction to writing algorithms Krishna Chaytaniah
 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxjacksnathalie
 
Tutorial presentation
Tutorial presentationTutorial presentation
Tutorial presentationkaeldrid
 
Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdffazanmobiles
 
Generators & Decorators.pptx
Generators & Decorators.pptxGenerators & Decorators.pptx
Generators & Decorators.pptxIrfanShaik98
 
MusicEngine for Unity/ADX2LE(English)
MusicEngine for Unity/ADX2LE(English)MusicEngine for Unity/ADX2LE(English)
MusicEngine for Unity/ADX2LE(English)Sho Iwamoto
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxSaqlainYaqub1
 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfaddtechglobalmarketi
 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfprajeetjain
 
Program by Demonstration using Version Space Algebra
Program by Demonstration using Version Space AlgebraProgram by Demonstration using Version Space Algebra
Program by Demonstration using Version Space AlgebraMaeda Hanafi
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxpriestmanmable
 
C programming perso notes
C programming perso notesC programming perso notes
C programming perso notesMelanie Tsopze
 
Programming intro variables constants - arithmetic and assignment operators
Programming intro variables   constants - arithmetic and assignment operatorsProgramming intro variables   constants - arithmetic and assignment operators
Programming intro variables constants - arithmetic and assignment operatorsOsama Ghandour Geris
 
PopMAG: Pop Music Accompaniment Generation
PopMAG: Pop Music Accompaniment GenerationPopMAG: Pop Music Accompaniment Generation
PopMAG: Pop Music Accompaniment Generationivaderivader
 
Chapter 2.4
Chapter 2.4Chapter 2.4
Chapter 2.4sotlsoc
 
2 Getting To Know Your Programing Environment
2 Getting To Know Your Programing Environment2 Getting To Know Your Programing Environment
2 Getting To Know Your Programing EnvironmentdM Technologies
 

Similar to Instructions This project focuses on queues and stacks Foll.pdf (20)

BeepComp - Chiptune Creator - User's Guide (v0.2.2)
BeepComp - Chiptune Creator - User's Guide (v0.2.2)BeepComp - Chiptune Creator - User's Guide (v0.2.2)
BeepComp - Chiptune Creator - User's Guide (v0.2.2)
 
91718032 tutorial-hidrogen
91718032 tutorial-hidrogen91718032 tutorial-hidrogen
91718032 tutorial-hidrogen
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Introduction to writing algorithms
Introduction to writing algorithmsIntroduction to writing algorithms
Introduction to writing algorithms
 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docx
 
Rap Lyric Generator
Rap Lyric GeneratorRap Lyric Generator
Rap Lyric Generator
 
Tutorial presentation
Tutorial presentationTutorial presentation
Tutorial presentation
 
Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdf
 
Generators & Decorators.pptx
Generators & Decorators.pptxGenerators & Decorators.pptx
Generators & Decorators.pptx
 
MusicEngine for Unity/ADX2LE(English)
MusicEngine for Unity/ADX2LE(English)MusicEngine for Unity/ADX2LE(English)
MusicEngine for Unity/ADX2LE(English)
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdf
 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdf
 
Program by Demonstration using Version Space Algebra
Program by Demonstration using Version Space AlgebraProgram by Demonstration using Version Space Algebra
Program by Demonstration using Version Space Algebra
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
C programming perso notes
C programming perso notesC programming perso notes
C programming perso notes
 
Programming intro variables constants - arithmetic and assignment operators
Programming intro variables   constants - arithmetic and assignment operatorsProgramming intro variables   constants - arithmetic and assignment operators
Programming intro variables constants - arithmetic and assignment operators
 
PopMAG: Pop Music Accompaniment Generation
PopMAG: Pop Music Accompaniment GenerationPopMAG: Pop Music Accompaniment Generation
PopMAG: Pop Music Accompaniment Generation
 
Chapter 2.4
Chapter 2.4Chapter 2.4
Chapter 2.4
 
2 Getting To Know Your Programing Environment
2 Getting To Know Your Programing Environment2 Getting To Know Your Programing Environment
2 Getting To Know Your Programing Environment
 

More from adinathknit

It had been seven weeks since her surgery and Marlene was On.pdf
It had been seven weeks since her surgery and Marlene was On.pdfIt had been seven weeks since her surgery and Marlene was On.pdf
It had been seven weeks since her surgery and Marlene was On.pdfadinathknit
 
ISuppose that the marginal propensity to save is dya5057y+.pdf
ISuppose that the marginal propensity to save is dya5057y+.pdfISuppose that the marginal propensity to save is dya5057y+.pdf
ISuppose that the marginal propensity to save is dya5057y+.pdfadinathknit
 
IT 7113 Data Visualization and Dashboard Development Project.pdf
IT 7113 Data Visualization and Dashboard Development Project.pdfIT 7113 Data Visualization and Dashboard Development Project.pdf
IT 7113 Data Visualization and Dashboard Development Project.pdfadinathknit
 
issurecoit thevend at teedes ERetiat a patin puinen ra soo .pdf
issurecoit thevend at teedes ERetiat a patin puinen ra soo .pdfissurecoit thevend at teedes ERetiat a patin puinen ra soo .pdf
issurecoit thevend at teedes ERetiat a patin puinen ra soo .pdfadinathknit
 
ISO 9000 uluslararas kalite standarddr Standardn en son dei.pdf
ISO 9000 uluslararas kalite standarddr Standardn en son dei.pdfISO 9000 uluslararas kalite standarddr Standardn en son dei.pdf
ISO 9000 uluslararas kalite standarddr Standardn en son dei.pdfadinathknit
 
Isabella Penrose la gerente general le pidi a la Sra Sul.pdf
Isabella Penrose la gerente general le pidi a la Sra Sul.pdfIsabella Penrose la gerente general le pidi a la Sra Sul.pdf
Isabella Penrose la gerente general le pidi a la Sra Sul.pdfadinathknit
 
Isaiah is a 9 vear old malewho was diaanosed with Cerebra.pdf
Isaiah is a 9 vear old malewho was diaanosed with Cerebra.pdfIsaiah is a 9 vear old malewho was diaanosed with Cerebra.pdf
Isaiah is a 9 vear old malewho was diaanosed with Cerebra.pdfadinathknit
 
Is there convincing evidence that less than half of American.pdf
Is there convincing evidence that less than half of American.pdfIs there convincing evidence that less than half of American.pdf
Is there convincing evidence that less than half of American.pdfadinathknit
 
Is the following statement true or false and why this sta.pdf
Is the following statement true or false and why this sta.pdfIs the following statement true or false and why this sta.pdf
Is the following statement true or false and why this sta.pdfadinathknit
 
Is the coefficient 0 1 or not defined Please provide expl.pdf
Is the coefficient 0 1 or not defined Please provide expl.pdfIs the coefficient 0 1 or not defined Please provide expl.pdf
Is the coefficient 0 1 or not defined Please provide expl.pdfadinathknit
 
Is the drawn T the doubled version of T If not what is th.pdf
Is the drawn T the doubled version of T If not what is th.pdfIs the drawn T the doubled version of T If not what is th.pdf
Is the drawn T the doubled version of T If not what is th.pdfadinathknit
 
Is SPI filtering for packets that are part of ongoing commun.pdf
Is SPI filtering for packets that are part of ongoing commun.pdfIs SPI filtering for packets that are part of ongoing commun.pdf
Is SPI filtering for packets that are part of ongoing commun.pdfadinathknit
 
Is it possible to create a bottom navigation with two option.pdf
Is it possible to create a bottom navigation with two option.pdfIs it possible to create a bottom navigation with two option.pdf
Is it possible to create a bottom navigation with two option.pdfadinathknit
 
Is gain of function correct Colors indicate range of gene e.pdf
Is gain of function correct Colors indicate range of gene e.pdfIs gain of function correct Colors indicate range of gene e.pdf
Is gain of function correct Colors indicate range of gene e.pdfadinathknit
 
irketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdf
irketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdfirketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdf
irketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdfadinathknit
 
irketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdf
irketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdfirketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdf
irketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdfadinathknit
 
Ire ntanin Cedar of ontry into recinient cell Given the abo.pdf
Ire ntanin Cedar of ontry into recinient cell Given the abo.pdfIre ntanin Cedar of ontry into recinient cell Given the abo.pdf
Ire ntanin Cedar of ontry into recinient cell Given the abo.pdfadinathknit
 
IP Fragmentation Consider sending a 2000 byte datagram in.pdf
IP Fragmentation Consider sending a 2000 byte datagram in.pdfIP Fragmentation Consider sending a 2000 byte datagram in.pdf
IP Fragmentation Consider sending a 2000 byte datagram in.pdfadinathknit
 
Investors have a utility function over wealth of Retur.pdf
Investors have a utility function over wealth of   Retur.pdfInvestors have a utility function over wealth of   Retur.pdf
Investors have a utility function over wealth of Retur.pdfadinathknit
 
Investors have different risk preferences Most people are n.pdf
Investors have different risk preferences Most people are n.pdfInvestors have different risk preferences Most people are n.pdf
Investors have different risk preferences Most people are n.pdfadinathknit
 

More from adinathknit (20)

It had been seven weeks since her surgery and Marlene was On.pdf
It had been seven weeks since her surgery and Marlene was On.pdfIt had been seven weeks since her surgery and Marlene was On.pdf
It had been seven weeks since her surgery and Marlene was On.pdf
 
ISuppose that the marginal propensity to save is dya5057y+.pdf
ISuppose that the marginal propensity to save is dya5057y+.pdfISuppose that the marginal propensity to save is dya5057y+.pdf
ISuppose that the marginal propensity to save is dya5057y+.pdf
 
IT 7113 Data Visualization and Dashboard Development Project.pdf
IT 7113 Data Visualization and Dashboard Development Project.pdfIT 7113 Data Visualization and Dashboard Development Project.pdf
IT 7113 Data Visualization and Dashboard Development Project.pdf
 
issurecoit thevend at teedes ERetiat a patin puinen ra soo .pdf
issurecoit thevend at teedes ERetiat a patin puinen ra soo .pdfissurecoit thevend at teedes ERetiat a patin puinen ra soo .pdf
issurecoit thevend at teedes ERetiat a patin puinen ra soo .pdf
 
ISO 9000 uluslararas kalite standarddr Standardn en son dei.pdf
ISO 9000 uluslararas kalite standarddr Standardn en son dei.pdfISO 9000 uluslararas kalite standarddr Standardn en son dei.pdf
ISO 9000 uluslararas kalite standarddr Standardn en son dei.pdf
 
Isabella Penrose la gerente general le pidi a la Sra Sul.pdf
Isabella Penrose la gerente general le pidi a la Sra Sul.pdfIsabella Penrose la gerente general le pidi a la Sra Sul.pdf
Isabella Penrose la gerente general le pidi a la Sra Sul.pdf
 
Isaiah is a 9 vear old malewho was diaanosed with Cerebra.pdf
Isaiah is a 9 vear old malewho was diaanosed with Cerebra.pdfIsaiah is a 9 vear old malewho was diaanosed with Cerebra.pdf
Isaiah is a 9 vear old malewho was diaanosed with Cerebra.pdf
 
Is there convincing evidence that less than half of American.pdf
Is there convincing evidence that less than half of American.pdfIs there convincing evidence that less than half of American.pdf
Is there convincing evidence that less than half of American.pdf
 
Is the following statement true or false and why this sta.pdf
Is the following statement true or false and why this sta.pdfIs the following statement true or false and why this sta.pdf
Is the following statement true or false and why this sta.pdf
 
Is the coefficient 0 1 or not defined Please provide expl.pdf
Is the coefficient 0 1 or not defined Please provide expl.pdfIs the coefficient 0 1 or not defined Please provide expl.pdf
Is the coefficient 0 1 or not defined Please provide expl.pdf
 
Is the drawn T the doubled version of T If not what is th.pdf
Is the drawn T the doubled version of T If not what is th.pdfIs the drawn T the doubled version of T If not what is th.pdf
Is the drawn T the doubled version of T If not what is th.pdf
 
Is SPI filtering for packets that are part of ongoing commun.pdf
Is SPI filtering for packets that are part of ongoing commun.pdfIs SPI filtering for packets that are part of ongoing commun.pdf
Is SPI filtering for packets that are part of ongoing commun.pdf
 
Is it possible to create a bottom navigation with two option.pdf
Is it possible to create a bottom navigation with two option.pdfIs it possible to create a bottom navigation with two option.pdf
Is it possible to create a bottom navigation with two option.pdf
 
Is gain of function correct Colors indicate range of gene e.pdf
Is gain of function correct Colors indicate range of gene e.pdfIs gain of function correct Colors indicate range of gene e.pdf
Is gain of function correct Colors indicate range of gene e.pdf
 
irketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdf
irketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdfirketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdf
irketlerin zellikleri ile ilgili olarak aadakilerden hangis.pdf
 
irketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdf
irketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdfirketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdf
irketimizin aadaki nakit aklarna sahip bir projesi bulunmakt.pdf
 
Ire ntanin Cedar of ontry into recinient cell Given the abo.pdf
Ire ntanin Cedar of ontry into recinient cell Given the abo.pdfIre ntanin Cedar of ontry into recinient cell Given the abo.pdf
Ire ntanin Cedar of ontry into recinient cell Given the abo.pdf
 
IP Fragmentation Consider sending a 2000 byte datagram in.pdf
IP Fragmentation Consider sending a 2000 byte datagram in.pdfIP Fragmentation Consider sending a 2000 byte datagram in.pdf
IP Fragmentation Consider sending a 2000 byte datagram in.pdf
 
Investors have a utility function over wealth of Retur.pdf
Investors have a utility function over wealth of   Retur.pdfInvestors have a utility function over wealth of   Retur.pdf
Investors have a utility function over wealth of Retur.pdf
 
Investors have different risk preferences Most people are n.pdf
Investors have different risk preferences Most people are n.pdfInvestors have different risk preferences Most people are n.pdf
Investors have different risk preferences Most people are n.pdf
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 

Instructions This project focuses on queues and stacks Foll.pdf

  • 1. Instructions This project focuses on queues and stacks. Following is the list of files that you need for this project. DO NOT CHANGE ANYTHING IN THESE FILES. NOT EVEN A SINGLE LINE! - StdAudio.java - Pitchjava - Accidentaljava - Note.java - Node.java - MelodyMainjava - Melody.java You will add all of your methods to MelodyQueue.javaYour job is to complete the class that represent a song: this class is called MelodyQueue. A song is comprised of a series of notes. It may have repeated sections. As we don't like to have any redundancy, we will only store one copy of a repeated chunk of notes. Music is usually printed like the example above. The notes are a series of dots. Their position in relation to the lines determines their pitch and their tops and color, among other things, determine their length. Since it would be difficult for us to read input in this style, we will instead read input from a text file. An example input file is shown below: Each line in it represents a single note. The first number describes the length of the note in seconds. The letter that follows describes the pitch of the note, using the standard set of letters (AG) or R if the note is a rest. For notes other than rests, the third item on the line is the octave that the note is in and the following is the note's accidental value. The final piece of information for all notes is true if the note is the start or stop of a repeated section and false otherwise. You will implement several methods in the MelodyQueue class which will allow you to use MelodyMain to play your song with mp3 player like functionality. Your melody will be able to play as well as append another melody to itself, reverse and have the it's tempo changed.You will add methods to the class: MelodyQueue.java. You must use Java's Stack and Quetie from java.util. You must use them as stacks and queues; you may NOT USE anything else that we have not discussed in the class such as: iterators, iterables or anything of that sort. Your class must have the constructorsimethods below. It must be possible to call the methods multiple times in any order and get the correct results each time. Your MelodyQueue class will use a queue to store the notes in the song (all quepes have pointer to the back and to the front). Bat unless otherwise specified, you may not create any other auxiliary data structures (such as arrays, lists, stacks, quetes) to help you solve any method below.MelodyQueue . java (for you to implement): public MelodyQueue () Constructor with no parameters public void enqueue (Object item) Adds item to the back of the queue. Make sure to cover the case that queue is null. public Object dequeue () Removes and returns item from the front of queve. If the queue is null print a message that queve is null. public Boolean isEmpty () Checks if queue is empty. public double duration () Returns duration/time of queue. In other words, it returns the total length of the song in seconds. If the song includes a repeated section the length should include that repeated section twice. For example, the sample file shown on previous page have length 3.6. public double timeRepeat () This is an auxiliary method that you will call in duration method. The job of this method is to find the duration of repeated sectionsReturns the size of the queve public String makestring() Returns String version of the notes in the queve. In other words, it returns a String containing information about each note. Each note should be on its own line similar to example on page 2. Your String should reflect the changes that have been made to the song by calling other methods. public void tempochange (double tempo) Changes the tempo of each note to be tempo percent of what it formerly was. Passing a tempo of 1.0 will make the tempo stay the same. Tempo of 2.0 will make each note twice as long, so it will be slower. Tempo of 0.5 will make each note half as long (make it faster). Keep in mind that when the tempo changes the length of the song also changes. public void playRepeat() Again, this is an auxiliary
  • 2. method. You will use it in play method. The job of this method is to play the repeated sections. public void appendMelody (MelodyQueue other) Adds one melody at the end of another one. In other words, it adds all notes from the other song (input parameter) to the end of this song. For example, if this song is A,F,G,B and the other song is F, C, D, your method should change this song to be A, F, G, B, F, C, D. The other song should be unchanged after the call.public MelodyQueue reverseMelody () Reverses the order of the notes of a song. This method reverses the order of notes in the song, so that future calls to the play methods will play the notes in the opposite of the order they were in before reverse was called. For example, a song containing notes A, F, G, then B would become B, G, F, A. You must use a temporary Stack to help you solve this problem. public void play () Plays the song. Must call the playRepeat method. This method plays the song by calling each note's play method. The notes should be played from the beginning of the queue to the end unless there are notes that are marked as being the beginning or end of a repeated section. When the first note that is a beginning or end of a repeated section is found you should create a second queue. You should then get notes from the original queue until you see another marked as being the beginning or end of a repeat.As you get these notes you should play them and then place them back in both queues. Once you hit a second marked as beginning or end of a repeat you should play everything in your secondary queue and then retum to playing from the main queue. It should be possible to call this method multinle times and get the same result. B The yellow blocks represent notes with start or end of a repeat set to true. They and the other notes in between them should be moved to a separate queue when played so that they can be repeated.Note Class and Melody Class (provided): You are provided with a class named Note class that your MelodyQueue use. A Note object represents a single musical note that will form part of a melody. It keeps track of the length (duration) of the note in seconds, the note's pitch (A- G, or R if the note is a rest), the octave, and the accidental (sharp, natural or flat). Each Note object also uses keeps track of whether it is the first or last note of a repeated section of the melody. The Melody class is just an Interface that will use the methods you created in your MelodyQueve class. The Note class provides the following constructors and methods that you should use in yourYou can look at the contents of the provided Notejava to answer any further questions about how it wotks. Development Strategy and Hints: 1 suggest the following development strategy for solving this project: 1. Add all of the describe methods to the MelodyQueve class. Leave every method's body blank: if necessary, return a "dummy" value like null or 0 . Get your code to run in the MelodyMain program, though the output will be incorrect. 2. Implement the constructor, and the makeString methods: 3. Implement the deration and changeTempo methods. You can check the results of the changeTempo method by reading in one of the sample files, calling changeTempo and then calling the makestring method and cliecking your output matches what you expected. 4. Complete the reverse and append methods. 5. Write an initial version of play0 that assumes there are no repeating sections. 6. Add the play0) code that looks for repeated sections and plays them twice, as described previously. You can test the outpot of your program by running it on various inputs in the MelodyMain client. Other blats? Take a look at the Node class. For the project 2, you worked with similar Node class but here the one variable of the Node class is different: private cbject item? private Node nexti5. Wneramanat verstouror phyonuaratssumes utre are io repeaimg seculous, 6. Add the play() code that looks for
  • 3. repeated sections and plays them twice, as described previously. You can test the output of your program by running it on various inputs in the MelodyMain client. Other hints: Take a look at the Node class. For the project 2, you worked with similar Node class but here the one variable of the Node class is different: private Object item; private Node next; For this project the item that one Node will be holding is a Note with all its features (Pitch. duration...). We have a queve of nodes where each Node holds a Note. You can check read method in MelodyMainjava to see how the queue is populated with the Notes. In other words, how the song is created! Next question is how we can play the song. For that, you don't have to do anything because in class Note the method play is added. You just have to use it: To play the notes int the queue, I can traverse the queue from front to back (the provided references for the queve). Remember this queue contains Nodes. To access to the content of a Note that is saved in a Node, we have to do the following: (let's refer to the Node as current): ( (Note) current.getrtem( ()) -play () ; We need to do the typecasting to convert the Node to a Note, othervise we receive an error. Similarly in any other methods of the MelodyQueue, whenever you need to get access to the Note inside a Node, you must do this typecasting.II When the progran starts, type load and enter the name of the file you want to play II You can then type play to hear it or any of the other comands to test your Melody's II other functionality.private static void intro() { Systen.out.println("Melcone to MelodyMain. Type the word in the left colum to do the action on the right"); Systen.out.printlin("load : load a new input file"); Systen.out.println("save : output to a file"); Systee. out.println("print : prints the contents of the last loaded song"); System.out.printin("play : play the last loaded song"); System.out.println("reverse : reverse the last loaded song"); System.out.println("duration : print out the length of the last loaded song in seconds"); System.out.println("tempo : change the speed by a percentage"); System.out.printlin("append : appends notes from a second melody to the loaded one"); System.out.println("quit : exit the program"); } II Checks to eake sure the file exists. Prompts the user for a new file until they II input a valid one. Returns a file that exists. Renember that the file should be in the II sane project folder. public static File checkFile(String name, Scanner console) f I File file = new File(name); while (Ifile.exists()) { System.out.print("Invalid file. File name? "); file= new File( console.next ()); ). 3 II Returns a Melodyqueue filled with the notes specified in the provided II Scanner. The notes will appear in the same order in the Melodyqueue II as they did in the file. public static MelodyQueve read (Scanner input) f Melodyqueue song = new Melodyqueve();lic class Note { private Pitch note; private double duration; private int octave; private Accidental accidental; private boolean repeat; I/ pre : duration > and octave =1, //otherwise throws an IllegalArgumentException II constructs a note with the provided duration, pitch, octave, accidental and repeat settings. public Mote(double duration, Pitch note, int octave, Accidental accidental, boolean repeat) { if(duration <= octave < octave >10){ throw new IllegalArgumentException(); 3 this. note = note; this.duration = duration; this octave = octave; this . accidental = accidental this .repeat = repeat; 3 II pre : duration >, otherwise throws an IllegalArgumentException II constructs a note with the passed in duration, pitch and repeat settings. public Mote(double duration, Pitch note, boolean repeat) { this(duration, note, , Accidental.MATURAL, repeat); 3 II returns the length of the note in secondsII constructs a note with the passed in duration, pitch and repeat settings. public Mote(double duration, Pitch note, boolean repeat) { this(duration, note, 0 , Accidental.MATURAL, repeat); } II returns the length of
  • 4. the note in seconds public double getDuration() { return duration; } II returns the Accidental value of the note public Accidental getAccidental() { return accidental; } II returns the octave of the note public int getoctave() { return octave; } II returns the pitch of the note (A - G or R of it is a rest) public Pitch getpitch() { return note; 3 II pre : d must be greater than , otherwise an IllegalArgumentException is thrown II sets the duration of the note to be the given time public void setDuration(double d) { if (d<=){ throw new IllegalArgumentException(); pre : d must be greater than , otherwise an IllegalArgumentException is thrown II sets the duration of the note to be the given time public void setDuration(double d) { if (d<=){ throw new IllegalArgumentException(); duration =d; I/ sets the accidental of the note to be the given accidental public void setAccidental(Accidental a) { accidental =a } // pre : octave must be greater than 0 and less than 10, II otherwise an IllegalArgumentException is thrown II sets the octave of the note to be the passed in octave public void set0ctave(int octave) { if(octave <0 octave >10 ) { throw new IllegalArgumentException(); } this octave = octave; 3 II sets the pitch of the note to be the passed in pitch public void setPitch(Pitch pitch) { note = pitch; }I/ sets the pitch of the note to be the passed in pitch public void setpitch(Pitch pitch) { note = pitch; I/ sets the repeat of the note to be the passed in repeat public void setRepeat(boolean repeat) { this. repeat = repeat; } II returns true if the note is the beginning or ending note in a repeated section, II false otherwise public boolean isRepeat() { } II plays the sound this note represents public void play() { StdAudio.play(duration, note, octave, accidental); II Otherwise returns a string in the format: public String tostring() { 4 SHARP true" and "1.5 R true". if(note.equals(Pitch. R )) { } else {I/ plays the sound this note represents public void play() { } StdAudio.play(duration, note, octave, accidental); II otherwise returns a string in the format: II For example "2.3 A 4 SHARP true" and "1.5 R true". public String tostring() { if(note.equals(Pitch.R)) { return duration ++ note ++ + + repeat; } else { 3 return duration +"+ note +"+ octave +" " + accidental +"=+ repeat; }public class MelodyQueve { private Node front; private Node back; //Add all of your methods to this class. DO NOT CHAVGE ANY OTHER CLASSESIIII public MelodyQueve() front = null; back = null; } public void enqueve (Object item){ 33