Question: Problem 2 : TimeSpanDesign and implement a TimeSpan class which represents a duration of time in hours, minutes, and seconds. The order hours, minutes, and

Problem 2: TimeSpanDesign and implement a TimeSpan class which represents a duration of time in hours, minutes, and seconds. The order hours, minutes, and seconds should be respected in the constructor.As an example TimeSpan duration(1,2,3);is a duration of time of 1 hour, 2 minutes and 3 seconds.In the instances of the TimeSpan class you should store the values as integers in a normalized way. The number of seconds should be between -60 and 60 when stored; number of minutes should be between -60 and 60 when stored. That is, a user can create a TimeSpan object of 90 seconds, but it should be stored as 1 minute, 30 seconds. See example below.You do not need to worry about integer overflow for very big TimeSpan objects.Accessor functions requiredThe TimeSpan class should implement the following member functions:int hours() const; return the number of hours as an intint minutes() const; return the number of minutes as an int int seconds() const: return the number of Seconds as an intvoid set_time(int hours, int minutes, int seconds): set the number of hours, minutes, seconds.ConstructorsThe class should define constructor(s) that receive various primitive types (specifically int, float, and double) and store

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!