UMBC CS 201, Spring 03
UMBC CMSC 201 Spring '03 CSEE | 201 | 201 S'03 | lectures | news | help

CMSC 201
Programming Project Three

Karaoke

Out: Tuesday 4/1/03
Due: before Midnight, Sunday 4/13/03

The design document for this project, design3.txt ,
is due: Before Midnight, Monday 4/7/03

The Objective

This project will give you practice using good design techniques, separate compilation, random numbers, Unix redirection, nested structures, and arrays of structures.

The Background

Ms. Block and I have enjoyed going to karaoke every week for quite a few years now. We always have a good time and have made many friends. To quote a friend of ours, Stan the (Trash)Man, "You need two kinds of people for karaoke: singers and clappers." As you'll see from the data file given for this project, I am a singer and Ms. Block still refuses to do so. She is, however, an enthusiastic listener and an avid clapper.

For those of you who are not familiar with karaoke, here is an explanation. There are karaoke hosts, similar to D.J.s, who can be hired for entertainment. A karaoke host has all of his own sound equipment, microphones, and a TV monitor. He buys special karaoke disks that have the music for popular songs, as recorded by a particular artist with the artists voice track removed, and the words to be sung added. So when a karaoke disk is played, you hear the music and the words that are to be sung appear on a TV monitor. As you progress through the song, the words change color so the singer doesn't lose his place.

A good karaoke host will have hundreds of disks, indicated by a thick song book. The song book typically has two sections. The first section has all the songs available sorted by song title and the second section has all the songs available sorted by artist. Each line in the book lists the song's title, artist, and the disk number and track on which it's found.

If you want to sing a song, you must fill out a song slip and give it to the karaoke host. The slip must contain your name, the song title, and the song number (which is the disk and track). The karaoke host keeps the slips in the order he receives them from the singers, establishing what is known as a "rotation". If a new singer comes in, s/he is added to the end of the rotation, not into the current position in the rotation. For example: The original rotation is Karaoke_Jim, Sue, Ben and Trashman. These 4 singers may have sung many songs each when a new singer, Dave_T, hands the host a slip while Sue is singing. Dave_T does NOT get to sing after Sue, but is added to the end of the rotation, making the new rotation Karaoke_Jim, Sue, Ben, Trashman and Dave_T. Singers get extremely aggravated by karaoke hosts who do not handle their rotations properly.

Our karaoke host is Karaoke_Jim of KJ Music Factory. He runs karaoke at the Karaoke House 5 nights a week. He has established himself there as a good host by providing a large song book, having a fair rotation practice and by providing his customers with some additional services. Since most singers have favorite songs that they've practiced and "perfected", a singer will find themselves filling out song slips for the same songs over and over again, week after week. Karaoke_Jim pampers us by keeping a database of each of his regular singer's songs and providing us with individualized pre-printed song slips.

The Task

Your task is to simulate an evening of karaoke at the Karaoke House by using the data provided in the data file called karaoke.dat. You must use Unix redirection to read the contents of this file into your program. Since the output from your program will be quite large, I suggest that you also use Unix redirection to capture the output into a file, which can then be viewed using the Unix command more.

Since you are Jim's helper, your program will have to print out slips for the singers before the evening begins.

To simulate the evening, you'll print out each singer's name, what song s/he sang and its song number in the order that they were sung. A singer is to randomly choose a song from his list of songs but cannot sing the same song again that evening.

In order to make sure you are reading from the file properly and to later make sure that your program has kept track of the number of times sung, etc., you should have a function that prints out all of the information for each singer and each of his/her songs. See the sample output file for details.

More details

The data file

The name of the data file is karaoke.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 command exactly :

cp /afs/umbc.edu/users/s/b/sbogar1/pub/karaoke.dat .

The space and the . (dot) at the end of the command are necessary and a part of the command.

Sample Output

Since the output file is enormous, instead of showing the output here, I am just providing a link to my output file, test.out

Sample Compilation & Program Run

linux1[101] gcc -c -Wall -ansi proj3.c linux1[102] gcc -c -Wall -ansi karaoke.c linux1[103] gcc -c -Wall -ansi util.c linux1[104] gcc proj3.o karaoke.o util.o linux1[105] a.out < karaoke.dat > test.out linux1[106] Although your output may look different than mine, you should print out the same information.

What to Turn In

You must use separate compilation for this project and should have a file, called proj3.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 project 2 and they should have been in your util.c file. Many of you will be able to reuse the util.c and util.h files you created for that project without any modification. (Make sure the file descriptions in those files doesn't mention proj2 - they shouldn't have anyway)

Submit as follows:

submit cs201 Proj3 proj3.c karaoke.c karaoke.h (followed by any other .c & .h files you have)

The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project are listed.