CMSC 201 Karaoke Revisited
Out: Monday 4/30/07
The design document for this project, design5.txt ,
|
We used a very simplistic (and unrealistic) approach to the problem of singing karaoke in project 3. In that project we had 10 singers and each singer had 10 songs. All of the singers were present at the beginning of the night and stayed until closing and were taken in the order they appeared in the data file. The data files were also set up so that no singer could sing a song that someone else had already sung, since no song titles were repeated. We all know that it doesn't happen this way.
This project will simulate karaoke in a much more realistic manner. Singers can come in at any time during the evening and be added to the rotation at that time. Singers may also leave at any time and should be removed from the rotation at that time. It is possible that several singers might have the same song in their song list. In reality, the karaoke host will not let a singer sing a song that someone else has already sung that evening.
Then you will read from the events.dat file and store the information in an array of EVENTS called events. The events are in order by the time they occur and consist of the time, a singer's name, and whether the singer is ENTERing or EXITing. The first number in the file is the number of events in the file.
Although it might be nice to print out all of the singers slips when s/he first arrives, we'll assume that has already been done to shorten your output.
To simulate the evening, you must keep track of the time. We will be working in intervals of 5 minutes, as before, and assume that a person can sing a song in 5 minutes. The evening of karaoke will be from 8:00 PM until 1:30 AM. All times given in the events file are guaranteed to be on a 5 minute interval. Several events can happen at the same time. You should handle all of the events in the events array for the current time and then let a singer sing in that time interval as well. (See sample output)
A singer is to randomly choose a song from his list of songs but cannot sing the same song again that evening. A singer also may not choose a song from his list that has been sung by someone else that evening. You must have an array of strings of sungSongs that can be checked for the song title to avoid repeats. You must use the song title for this, not the song number, since more than one artist might have recorded a song and those different renditions are considered to be the same song even though they would have different song numbers. If the randomly-chosen song is a song that has already been sung, randomly chose another song.
As new singers arrive (ENTER), they are to be removed from the list of singers and added to the end of the rotation linked list and as they leave (EXIT), they should be removed from the rotation list and put back into the list of singers.
As always, you should have several debugging functions that you can call during the implementation stage of programming to make sure that each list contains what it should, that you managed to read properly from the files, etc.
Since singers now have different numbers of slips, you can no longer just have an array of SLIPs of size 10 in the SINGER structure. You should have a member that contains the number of slips and you'll need to dynamically allocate the space needed to store that many SLIPs. This memory's address should be stored in the structure and can be used as an array. Some of the songs now have longer titles, so the size of a title should now be 40.
You must also have a struct of type EVENT. The definition is up to you.
The name of the data files are p5karaoke.dat and events.dat and can be viewed from this link. You should NOT view it and save it into a file or cut and paste it from the browser into a file. Either of these methods of obtaining the file may cause there to be extraneous characters in the file that your program will try to read and disrupt the input of your data. Instead you must copy the file from my directory into the directory that you'll be using to work on this project.
Go to that directory and then issue the following commands exactly :
cp /afs/umbc.edu/users/b/o/bogar/pub/p5karaoke.dat .
cp /afs/umbc.edu/users/b/o/bogar/pub/events.dat .
The space and the . (dot) at the end of the command are necessary and a part of the command.
For 5 points of extra credit, sort the array of sung songs and use binary search (rather than linear search) to determine if a song is in the array or not. Submit a file called README that tells the grader that you implemented the extra credit portion.
You must use separate compilation for this project and should have a file, called proj5.c, that contains only the function main(). You should also have karaoke.c and karaoke.h, that contain functions related karaoke and the prototypes for those functions, respectively. You may, of course, have other .c and .h files, as you see fit. You should realize that you will be reusing some functions that you wrote for previous projects and they should have been either in your karaoke.c file or in your util.c file. Many of you will be able to reuse the util.c and util.h files. You may use the linked list code from the lectures and it will work with only minor modifications.
Submit as in previous projects. Don't forget your .h files.