CSCI 235 Software Analysis & Design Spring, 2003
Instructor: Szenher
Programming Assignment #3: A Simple Class-Based Program
Due Date: 3/05/03
Objectives: This program will test your skills at designing and implementing a class-based program.
Problem Specification: Design and implement an ADT that represents the time of day. Represent the time as hours and minutes on a 24-hour clock (i.e. hour must be an integer between 0 and 23, inclusive, and minute must be an integer between 0 and 59, inclusive). The hours and minutes are the private data members of the class that implements the ADT.
Include at least two initialization operations: One that provides a default value for the time, and another that sets the time to a client-supplied value. These operations are the class's constructors.
Include operations that set the current hour and minute, return the current hour and minute, increase the present time by a number of minutes (amount to increase could be any positive number of minutes), and display the time in 12-hour (a.m. or p.m. required) and 24-hour notations.
Implementation: In addition to the class above, implement a short client function containing the
following code:
TimeOfDay t1;
t1.PrintTime12HourFormat();
t1.PrintTime24HourFormat();
t1.SetHour (13);
t1.SetMinute (46);
t1.PrintTime12HourFormat();
t1.PrintTime24HourFormat();
t1.IncreaseTimeByMinutes (60);
t1.PrintTime24HourFormat();
t1.IncreaseTimeByMinutes (1230);
t1.PrintTime12HourFormat ();
TimeOfDay t2 (18, 24);
t2.PrintTime12HourFormat ();
Required Testing: Demonstrate that your class produces the following output given the client code above:
0:0 a.m.
0:0
1:46 p.m
13:46
14:46
11:16 a.m.
6:24 p.m.