Question: Question 1 : Write a class Time from the following UML class diagram table [ [ TimeMachine ] , [ - hour: int ]

Question 1: Write a class Time from the following UML class diagram
\table[[TimeMachine],[-hour: int],[- minute : int],[- second: int],[+ setTime(int, int, int)],[+ FutureTravel(int, int,],[int)],[+ printTime()],[+ PastTravel(int, int,],[int)]]
In addition to the UML Class diagram's requirements, add 02 constructors, default and parametrized constructor. In the setTime method, add the validations for hour, minute and second.
FutureTravel() method should add the parameters to the hour, minute and second. Make sure to add appropriate data validation to make future travel logical.
PastTravel() method should subtract the parameters to the hour, minute and second. Make sure to add appropriate data validation to make past travel logical.printTime method should display time in 12 hours format.
Time can be stored in hour from 00 to 23 but this method should only display time in 12 hours format, for example, 15:25:30 should be displayed as 03:25:30 PM.
Write the main function, create a time instance and call all of the member functions to test the functionality of your class.
 Question 1: Write a class Time from the following UML class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!