JMU
MadisonMinuteMinder.gif
Madison Minute Minder


Background
Existing Components:
None: There are no existing components.
New Components:
The Duration Class: You must write a Duration class that encapsulates the duration of events (e.g. telephone calls).

At a minimum, it must have two int attributes that are used to hold the number of minutes and seconds in the Duration. The seconds must be in the interval [0, 60) and the minutes must be greater than or equal to 0.

At a minimum it must also have the following methods:

  • A default constructor (that initializes the Duration to 0 minutes and 0 seconds).
  • An explicit value constructor that is passed two int values containing the minutes and seconds (in that order).
  • A char *toString() method that returns a pointer to a character array that contains a nicely-formatted representation of a Duration. (Note: Think carefully about whether the memory for the character array should come from the stack or the heap and what that means for the caller.)

At a minimum it must also have the following operators:

  • A binary + operator that adds two Duration objects and returns a Duration object by value.
  • A binary - operator that subtracts the right-hand-side Duration from the left-hand-side duration and return a Duration object by value. The result must be 0 minutes and 0 seconds if the subtraction would result in a "negative duration".
  • A binary > operator that returns true if the left-hand-side Duration is greater than the right-hand-side Duration, and false otherwise.
  • A binary = operator that assigns the attributes of the right-hand-side duration to the attributes of the left-hand-side duration. (Note: It is very important to understand this operator and how it works because several methods in other classes will return a Duration object that will be assigned to another Duration object.)
The DurationHistory Class: You must write a DurationHistory class that encapsulates a history of event durations (e.g. a sequence of telephone calls). This class must use a doubly-linked linear data structure that is allocated dynamically. (You must write a Node class to support this data structure.)

This class must keep track of the first and last Duration entered in the history. It must also keep track of the "current" Duration (e.g., the most recently requested Duration).

At a minimum it must have the following methods:

  • A default constructor.
  • A destructor.
  • A void append(int minutes, int seconds) method that appends a new Duration object to the end of the history.
  • A Duration getFirst() method that returns the first Duration in the history and makes it the "current" Duration.
  • A Duration getLast() method that returns the last Duration in the history and makes it the "current" Duration.
  • A Duration getNext() method that returns the Duration in the history that is immediately after the "current" Duration. It must also make it the new "current" Duration.
  • A Duration getPrevious() method that returns the Duration in the history that is immediately before the "current" Duration. It must also make it the new "current" Duration.
  • A bool hasNext() method that returns true if there is a Duration in the history that is immediately after the "current" Duration and false otherwise.
  • A bool hasPrevious() method that returns true if there is a Duration in the history that is immediately before the "current" Duration and false otherwise.

Note the the various "get" methods will fail if they are called at inappropriate times. It is up to the caller to ensure that this does not happen.

The Minder Class: You must write a class named Minder that provides the main functionality of the Madison Minute Minder.

At a minimum, it must have a Duration attribute that stores the user's monthly allotment of minutes and a DurationHistory that keeps track of the user's telephone calls.

At a minimum it must have the following methods:

  • An explicit value constructor that is passed an int value that contains the user's monthly allotment of minutes.
  • A destructor.
  • A void addCall(int minutes, int seconds) method that adds a telephone call (with the given duration) to the history.
  • A Duration getTimeLeft() method that returns the amount of time still available to be used for telephone calls. (This method must return a duration of 0 minutes and 0 seconds if the entire allotment has been used.)
  • A Duration getTimeUsed() method that returns the amount of time used thus far (i.e., the total duration of all calls in the history).
  • A void reset(bool rollover) method that "clears" the history and gets the Minder ready for a new month. If the argument rollover is true the unused portion of the allotment should be "rolled over" into the new month. Otherwise, the new month should have the "normal" allotment.
Other Issues:
Drivers: You should write drivers to test all of your classes. Three "shells" of drivers are available:

They are not useful for testing purposes but they can give you and idea of kind of drivers that will be used on "submission day".

Advice:

I strongly suggest that you design, implement and test one class at a time. For the larger classes, I suggest that you design, implement and test one or two methods at a time.

I strongly suggest you use the make utility.

Copyright 2010