A
Modify the Time class(attached) to be able to work with Date class. The Time object should always remain in a consistent state.
Modify the Date class(attached) to include a Time class object as a composition, a tick member function that increments the time stored in a Date object by one second, and increaseADay function to increase day, month and year when it is proper. Please use CISP400V10A4.cpp that tests the tick member function in a loop that prints the time in standard format during iteration of the loop to illustrate that the tick member function works correctly. Be aware that we are testing the following cases:
- a) Incrementing into the next minute.
- b) Incrementing into the next hour.
- c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
- d) Incrementing into the next month and next year.
Time class
The Time class has three private integer data members, hour (0 – 23 (24-hour clock format)), minute (0 – 59), and second (0 – 59).
It also has Time, setTime, setHour, setMinute, setSecond, getHour(), getMinute, getSecond,~Time, printUniversal, and printStandard public functions.
- The Time function is a default constructor. It takes three integers and they all have 0 as default values. It also displays “Time object constructor is called.” message and calls printStandard and printUniversal functions.
- The setTime function takes three integers but does not return any value. It initializes the private data members’ (hour, minute and second) data.
- The setHour function takes one integer but doesn’t return anything. It validates and stores the integer to the hour private data member.
- The setMinute function takes one integer but doesn’t return anything. It validates and stores the integer to the minute private data member.
- The setSecond function takes one integer but doesn’t return anything. It validates and stores the integer to the second private data member.
- The getHour constant function returns one integer but doesn’t take anything. It returns the private data member hour’s data.
- The getMinute constant function returns one integer but doesn’t take anything. It returns the private data member minute’s data.
- The getSecond constant function returns one integer but doesn’t take anything. It returns the private data member second’s data.
- The Time destructor does not take anything. It displays “Time object destructor is called.” message and calls printStandard and printUniversal functions.
- The printUniversal constant function does not return or accept anything. It displays time in universal-time format.
- The printStandard constant function does not return or accept anything. It displays time in standard-time format.
Date class
The Date class has three private integer data members (month, day and year), one private Time object (time) data member and one static constant integer variable (monthsPerYear).
It has Date, print, increaseADay, tick, and ~Date public functions. It has one private checkDay function.
- The Date function is a default constructor. It takes 3 integers and one Time object. The three integers have default data (1, 2, and 1900) and the Time has (0, 0, and 0) as default data. It displays “Date object constructor for date” information when the constructor is called.
- The print constant function does not take or return data. It prints out the month day year, hour, minute and second information.
- The increaseADay function does not take or return data. It increases the private data member day by one. It also checks the day to make sure the data is accurate. If the data is not accurate it will adjust all the necessary corresponding data.
- The tick function does not take or return data. It increases one second to the Time object of the Date class private data member. This function has to make sure that the second increased is proper or it will adjust all the necessary corresponding data.
- The ~Date function is a destructor of the Date class. It also displays “Date object destructor is called “; message and calls Time object destructor.
- The constant checkDay function takes and returns an integer. It makes sure the accuracy of day, month, and year information. This utility function to confirm proper day value based on month and year, it also handles leap years, too.
This assignment comes with a CISP400V10A4.zip file. It includes six files (CISP400V10A4.cpp, CISP400V10A4.exe, Date.cpp, Date.h, Time.cpp and Time.h). The CISP400V10A4.exe file is an executable file. You can double click the file to get to the expecting result (see the picture below) of this assignment. The Date.cpp, Date.h, Time.cpp, and Time.h are files that you can use so you don’t need to start from scratch. After you finish your implementation for the Date and Time class, you can put the CISP400V10A4.cpp, Date.cpp, Date.h, Time.cpp, and Time.h in a project and then you can run to the same result as the CISP400V10A4.exe. Please be awarded that you can adjust only your program (Date.cpp, Date.h, Time.cpp and Time.h) to generate the required result but not the code in CISP400V10A4.cpp file.
The following are the couple displays of the expecting results.
The picture in the next column is the beginning section of the display. | |
The picture in the next column is the ending section of the display. |
Please document CISP400V10A4.cpp, Date.cpp, Date.h, Time.cpp, and Time.h files properly and zip them into a proper named zip file for an assignment (refer to the assignment section of the class syllabus) and submit it to the A4 dropbox of the D2L Website.
Worth 150 points
Reviews
There are no reviews yet.