<br><br>Term Project - 2<br><br>A MusicBox Using Polymorphism<br><br><br> <br><br>In this project you’ll write a MusicBox program that is asked to you in the lab midterm. The full description of the project and the minimum requirements are given below. You can make any improvements as you wish (such as being able to turn the musicbox on/off, copying records etc.). Although the header file “music.h” was given in the midterm, now you will implement also the header file, whose prototype is given below.<br><br>Implement a MusicBox that can play a Record (Plak). As you can see from the following figure, the MusicBox contains 3 buttons (or more depending on your own design):<br><br>· INSERT button allows you to insert a record into its drawer; and will be implemented by the insert method that requires a record object.<br><br>· EJECT button ejects the previously inserted record from its drawer; and will be implemented by the eject method.<br><br>· PLAY button plays the record that was inserted previously to its drawer; and will be implemented by the play method.<br><br><br><br>Record is an abstract base class for all types of records. In our system we will design and implement InstrumentalRecord (having only music) and VocalRecord (having music and song) that are subclasses of Record. Since Record is the base class it should have all the common properties of InstrumentalRecord and VocalRecord. So, inside the Record class you should provide a data structure to store the music that is common for all types of Records. music is simply an array of Notes. Note class will be implemented in the “music.h” header file.<br><br>//============ A MUSIC NOTE (MUZIK NOTASI)<br>class Note {<br><br> // note can take values from 0 to 6.<br> // 0:do, 1:re, 2:mi, 3:fa, 4:sol, 5:la, 6:si<br> int note;<br><br> // duration can take values from 1 to 3.<br> // note will be played duration seconds.<br> int duration;<br><br><br>public:<br><br> // default constructor generates a random note<br> // having a random duration<br> Note();<br><br> // displays the note in a readible format.<br> // format : note(duration)<br> // example: if note=0, duration=2 output will be do(2)<br> void play();<br><br>};<br>Implement the Record class that stores a pointer to an array of Notes and the length of music (number of Notes). Its only constructor (default constructor) generates a random record that means a record having a random number of random notes. Record class should also have a play method that provides us to play it. The maximum length of a Record should be 45 Notes.<br><br>Implement the InstrumentalRecord class deriving from the Record class. This InstrumentalRecord class implements a Record which has only music (array of Notes).<br><br>Implement the VocalRecord class deriving from the Record class. Other than having a music (array of Notes) that is inherited from the Record, it should also have a song, which is simply an array of Syllables (heceler). A VocalRecord’s each Note has a corresponding Syllable so; the lengths of music and the song are the same. Its only constructor (default constructor) generates a random record that means a record having a random number of random notes and the same number of random syllables. Syllable class will be implemented in the “music.h” header file. <br>//============ HECE (No need to be meaningful)<br>// Syllable is generated as a sequence of 1 vowel (sesli)<br>// followed by 1 consonant (sessiz) characters<br>class Syllable {<br><br> char syllable[3]; // syllable containing 3 characters<br> // vowel + consonant + null<br> // examples "ak", "el", "of".<br><br>public:<br> // default constructor generates a random syllable<br> // containing 2 characters; 1 vowel followed by 1 consonant<br> Syllable();<br><br> // displays the syllable<br> void play();<br><br>};<br>After completing the implementations of your classes, execute the following main: <br>void main() {<br><br> srand((int)time(NULL)); // initialize the random number generator<br><br> InstrumentalRecord vangelis; // create one InstrumentalRecord,<br> VocalRecord shakira; // one VocalRecord,<br> MusicBox sony; // and one MusicBox<br> // then perform MusicBox's methods<br> sony.play();<br> sony.eject();<br> sony.insert(vangelis);<br> sony.play();<br> sony.insert(shakira);<br> sony.eject();<br> sony.insert(shakira);<br> sony.play();<br> sony.eject();<br>}<br>Its output should be similar to the following: <br>Error(3) Cannot be played: There is no record in the drawer!<br>Error(2) Cannot be ejected: There is no record in the drawer!<br>Record is inserted.<br>Playing an instrumental:fa(3)-sol(3)-mi(2)-si(2)-mi(2)-mi(1)<br>Error(1) Cannot be inserted: First, you've to eject the inserted record!<br>Record is ejected.<br>Record is inserted.<br>Playing a song:up[la(1)]-ug[si(3)]<br>Record is ejected.<br>After completing this core part of the project you can do any improvements as you wish. One of the improvements you MUST perform is to overload at least one operator. A sample operator overload is given below:<br><br> VocalRecord mix = vangelis + shakira;<br> sony.insert(mix);<br> sony.play();<br>To be able to execute the first line (calculation) you have to overload '+' and '=' operators. '+' operator mixes its two operands, and then returning VocalRecord object is assigned to mix object by '=' overload. Mixing operation takes 1 InstrumentalRecord and 1 VocalRecord objects, then a new VocalRecord object is generated whose Note is taken from the InstrumentalRecord object and Syllable is taken from the VocalRecord object.<br><br>Its output should be similar to the following: <br>Records are mixed.<br>Record is inserted.<br>Playing a song:up[fa(3)]-ug[sol(3)]<br>Read the following note carefully!<br><br><br><br>