Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C++ (Please follow the instructions given and if possible please add comments, thank you) (It should ask for the input for time) Create a

Language: C++

(Please follow the instructions given and if possible please add comments, thank you)

(It should ask for the input for time)

Create a class called Time that has separate int member variables for hours, minutes, and seconds. Provide the following member functions for this class: 1. A no-argument constructor to initialize hour, minutes, and seconds to 0.

2. A 3-argument constructor to initialize the members to values sent from the calling function at the time of creation of an object. Make sure that valid values are provided for all the data members. In case of an invalid value, set the variable to 0.

3. A member function show() to display time in 11:59:59 format. You can also overload the << operator so that you can display the object directly. This will allow you to properly test your pre- and -post increment/decrement operators.

4. An overloaded operator+ for addition of two Time objects. Each time unit of one object must add into the corresponding time unit of the other object. Keep in view the fact that minutes and seconds of resultant should not exceed the maximum limit (60). If any of them do exceed, subtract 60 from the corresponding unit and add a 1 to the next higher unit.

5. Overloaded operators for pre- and post-increment. These increment operators should add a 1 to the seconds unit of time. Keep track that seconds should not exceed 60.

6. Overloaded operators for pre- and post-decrement. These decrement operators should subtract a 1 from seconds unit of time. If number of seconds goes below 0, take appropriate actions to make this value valid.

A main() program should create two initialized Time objects and one that isnt initialized. Then it should add the two initialized values together, leaving the result in the third Time variable. Finally it should display the value of this third variable. Check the functionalities of ++ and -- operators of this program for both pre- and post-incrementation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago