Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need your help,I am desperate please!!!!!!

Status
Not open for further replies.

touch

Programmer
May 11, 2000
3
0
0
TR
<br><br>Term Project - 2<br><br>A MusicBox Using Polymorphism<br><br><br>&nbsp;<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>·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EJECT button ejects the previously inserted record from its drawer; and will be implemented by the eject method.<br><br>·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>//============&nbsp;&nbsp;A MUSIC NOTE (MUZIK NOTASI)<br>class Note {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;note can take values from 0 to 6.<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;0:do, 1:re, 2:mi, 3:fa, 4:sol, 5:la, 6:si<br>&nbsp;&nbsp;&nbsp;&nbsp;int note;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;duration can take values from 1 to 3.<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;note will be played duration seconds.<br>&nbsp;&nbsp;&nbsp;&nbsp;int duration;<br><br><br>public:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;default constructor generates a random note<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;having a random duration<br>&nbsp;&nbsp;&nbsp;&nbsp;Note();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;displays the note in a readible format.<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;format : note(duration)<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;example: if note=0, duration=2 output will be do(2)<br>&nbsp;&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;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>//============&nbsp;&nbsp;HECE (No need to be meaningful)<br>//&nbsp;&nbsp;Syllable is generated as a sequence of 1 vowel (sesli)<br>//&nbsp;&nbsp;followed by 1 consonant (sessiz) characters<br>class Syllable {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;char syllable[3];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// syllable containing 3 characters<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// vowel + consonant + null<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// examples &quot;ak&quot;, &quot;el&quot;, &quot;of&quot;.<br><br>public:<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;default constructor generates a random syllable<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;containing 2 characters; 1 vowel followed by 1 consonant<br>&nbsp;&nbsp;&nbsp;&nbsp;Syllable();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;displays the syllable<br>&nbsp;&nbsp;&nbsp;&nbsp;void play();<br><br>};<br>After completing the implementations of your classes, execute the following main: <br>void main() {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;srand((int)time(NULL)); // initialize the random number generator<br><br>&nbsp;&nbsp;&nbsp;&nbsp;InstrumentalRecord vangelis; // create one InstrumentalRecord,<br>&nbsp;&nbsp;&nbsp;&nbsp;VocalRecord shakira;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one VocalRecord,<br>&nbsp;&nbsp;&nbsp;&nbsp;MusicBox sony;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;and one MusicBox<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// then perform MusicBox's methods<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.play();<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.eject();<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.insert(vangelis);<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.play();<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.insert(shakira);<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.eject();<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.insert(shakira);<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.play();<br>&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;VocalRecord mix = vangelis + shakira;<br>&nbsp;&nbsp;&nbsp;&nbsp;sony.insert(mix);<br>&nbsp;&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;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>
 
What work have you done so far already, and what help do you need with what you have done, because I will not do the work for you (We've had several post concerning Students posting their assigment without putting efforts towards them) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top