CS117 Debugging Assignment
Fall 1999
Goal
Below is the design for a programming problem. On the pages following is a solution to the problem, written in the language you are learning. Unfortunately, the solution has a major bug in it. Your task is to find the bug, using the methods outlined in class, and fix it in the simplest way you can.
Deliverables
Source code
You will need to compile and run the attached program.
You can download it by shift-clicking here: C, C++, Fortran, Java.
Problem statement:
Fit tracks on a CD to minimize the wasted space.
Problem description:
Read track times in mins:secs from a file. Allocate tracks on a CD by track number to minimize the wasted space. The total time available is 74 mins. Print out the tracks by number with their time on the screen. Print the total time used on the screen. If all the tracks can be allocated, print a warning message on the screen that not all the space has been used.
TDSR (for C and Fortran)
(see handout)
Object analysis (for C++)
Read track times in mins:secs from a file. Allocate tracks on a CD by track number to minimize the wasted space. The total time available is 74 mins. Print out the tracks by number with their time on the screen. Print the total time used on the screen. If all the tracks can be allocated, print a warning message on the screen that not all the space has been used.
track HAS-A time
track HAS-A number
CD HAS-A sequence of track
CD HAS-A timeAvailable
CD HAS-A timeUsed
Track
int time
unsigned int number
CD
Track track[]
int timeAvailable
int timeUsed
Method Analysis
Read track times in mins:secs from a file. Allocate tracks on a CD by track number to minimize the wasted space. The total time available is 74 mins. Print out the tracks by number with their time on the screen. Print the total time used on the screen. If all the tracks can be allocated, print a warning message on the screen that not all the space has been used.
TrackAllocator
CD cd
run()
CD
Track track[]
int timeAvailable
int timeUsed
allocate()
printTracks()
printTime()
printNotAllUsed()