CS12, Program 5

Assigned: May 25th, 2001

Due: June 8th, 2001, 10pm

 

 

Topics

 

Background

In this assignment you will again build on the Time class you started with in program 4. Start with one of the versions of the time class from the book (time3, on pages 423--424, or time5, pages 455--457). You do not need to type anything. It is all on the CD That came with the book. Put your class in a files called time.h and time.cc, and call the class Time. You will need to enhance the time list with comparison operators (==, <, >, <=. >=) to enable you to compare two time elements and determine which comes first. You may assume that all time objects refer to the same day.

Write a class for maintaining a sorted linked list of time information. Nodes in the list should have as their data field a pointer to a Time object. The class should have the following methods:

You may add more methods if you see fit, but please do not change the names, types and parameters of the methods above.

In order to test the functionality of your class, write a main() that uses each of the methods to show that they work (create a list, insert a few Time objects, delete an object, search for an object that is there, search for an object that isn’t there, etc.) Turn in your test program along with your class implementation.

Extra Credit

One of the advantages of inheritance is that you can create a linked list of objects of different types (related by inheritance) without defining in advance which type of object will be in the list. The data contained in a list node is a pointer to a base object, and the actual object and its type (base or inherited) is determined and dynamically bound at runtime.

Add to your list class the capability of storing both Time and ZonedTime objects. In order to compare Time objects and ZonedTime objects, you may assume that Time objects refer to local time (Pacific).

 

 

What to turn in