UMBC CS 201, Spring 07
Spring '07

CSEE | 201 | 201 S'07 | lectures | news | help

CMSC 201
Programming Project Three


Out: Monday 4/2/07
Due: before Midnight, Sunday 4/15/07

The design document for this project, design3.txt ,
is due: Before Midnight, Sunday 4/8/07

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

Mrs. Evans and Ms. Block have enjoyed going to karaoke every week for quite a few years now. They always have a good time and have made many friends. To quote one friend, 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, Mrs. Evans is 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 while 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 combination of the disk name and track number). 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 singers' 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

  1. You must use the following structure definitions : typedef struct slip { char singer[SINGER_NAME_SIZE]; char title[TITLE_SIZE]; char songNumber[SONG_NUMBER_SIZE]; int sung; } SLIP; typedef struct singer { SLIP slips[NUM_SLIPS]; int timesSung; } SINGER; where,
  2. There are 10 singers in the data file and each singer has 10 slips.
    Although each line of the data file contains the singer's name, a song title, and a song number, it does NOT contain the 0 indicating that the song has not been sung yet that evening. Your program must initialize this member for each slip. Similarly, your program needs to initialize the timesSung members of all the structures of type SINGER.

  3. After reading the information from the data file into your array of SINGERs and initializing the other members as mentioned in item #2, your program must print out all of the information. See the sample output file.
  4. Next your program must simulate the printing out all of the slips for each singer. Since there are 10 singers and each singer has 10 songs, your program will print out 100 slips. Your slips must be printed so that 2 slips fit side-by-side on an 80-wide screen. This is the most tedious part of the program and requires significant problem-solving thought on your part. Therefore, printing of the slips in any other format will receive NO CREDIT for that part of the correctness section. Please examine the sample output file, karaoke.out for the correct format. Your slips should be almost identical to the sample.
  5. Next your program should simulate the evening of singing songs.

  6. After the singing is done, you must again print out all of the information about each singer and each of his songs to make sure that your bookkeeping was accurate. Again see the sample output file for an example.
  7. Be aware that since we are all using a call to time() to seed the random number generator, your program will produce the singing of the songs in a different order than the sample and in fact will have a different order of songs sung for each time you run your program.

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/ .

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, here's a link to the sample output file, karaoke.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 -lm linux1[105] a.out < karaoke.dat > karaoke.out linux1[106] Although your output may look different than the sample output, you should print out all of 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 previous projects and they should have been in your util.c file. You will be able to reuse the util.c and util.h files you created without any modification. Of course, you may always add new modules to util.c if you want.

Submit as follows:

submit cs201 Proj3 proj3.c karaoke.c karaoke.h util.c util.h

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.

You can check your submittal by using submitls:

submitls cs201 Proj3

CSEE | 201 | 201 S'07 | lectures | news | help