Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use C++ and don't copy from other chegg answers please, thanks! Problem: TimeSpan Design and implement a TimeSpan class which represents a duration of time
Use C++ and don't copy from other chegg answers please, thanks!
Problem: TimeSpan Design 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; number of minutes should be between -60 and 60. You do not need to worry about integer overflow for very big TimeSpans. Accessor/Mutator functions required The TimeSpan class should implement the following member functions: int getHours() const; int getMinutes() const; int getSeconds() const: return the number of hours as an int return the number of minutes as an int return the number of Seconds as an int bool setTime(int hours, int minutes, int seconds): set the number of hours, minutes seconds and return true if successful. onstructo The class should define constructor(s) that receive various primitive types (specifically int, float, and double) and converts them to Int. Do appropriate rounding to maintain as much accuracy as possible. TimeSpan(1.5,4,-10) represents 1 hour, 33 minutes, 50 seconds If only one parameter is passed during initialization assume it is a second. If there are two assume minutes and seconds (in that order). Round the answer to the nearest second (for example, 50.9 seconds should be rounded to 51 seconds) TimeSpan(7, 3) represents 7 minutes, 3 seconds. Operators The class must overload and implement the following math operators: addition, subtraction, Unary Negation. The class must overload and implement the following comparisons:-, The class must implemenandassignment statements as well Stream /O The class must implement theStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started