Question: Question 1 : Write a class Time from the following UML class diagram table [ [ TimeMachine ] , [ - hour: int ]
Question : Write a class Time from the following UML class diagram
tableTimeMachinehour: int minute : int second: int setTimeint int, int FutureTravelint int,int printTime PastTravelint int,int
In addition to the UML Class diagram's requirements, add 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 logicalprintTime method should display time in hours format.
Time can be stored in hour from to but this method should only display time in hours format, for example, :: should be displayed as :: PM
Write the main function, create a time instance and call all of the member functions to test the functionality of your class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
