Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need some assistance with the following question: NOTE: This is a multi part assignment. First part: Create a class that will hold the information about

Need some assistance with the following question:

NOTE: This is a multi part assignment.

First part:

Create a class that will hold the information about a clock, called Clock. You need to keep minutes, hours and seconds in military time (24-hour) format. Include member functions that will setTime ( this will set the hours, minutes and seconds of the clock), getHours (return the hours), getMinutes (return the minutes) and getSeconds (return the seconds). Another method printTime which will print the time out like this 03:13:09 (hours:minutes:seconds). Overloaded constructors that will take in hours, minutes and seconds or the default constructor that will take in nothing and set hours, minutes and seconds all to 0.

Your class should also include the following methods

incrementSeconds()

//A method to increment the time by one second.

//The time is incremented by one second.

// If the before-increment time is

// 23:59:59, the time is reset to 00:00:00.

incrementMinutes()

//A method to increment the time by one minute.

// The time is incremented by one minute.

// If the before-increment time is

// 23:59:53, the time is reset to 00:00:53.

incrementHours()

//A method to increment the time by one hour.

// The time is incremented by one hour.

// If the before-increment time is

// 23:45:53, the time is reset to 00:45:53.

Second part:

- Show possible calls to do the following.

- Create a clock that is set to 9:0:0.

- Create another clock that is set to 9:30:20.

- Add one hour to the first clock.

- Add 30 minutes to the second clock.

Third part:

Using your clock class, create a child class, ClockChild. Create a constructor that calls the parents default constructor and an overloaded constructor that takes in hours, minutes and seconds and sets the member variables accordingly. Create a printTime method, for the child. Now it will take in a parameter called typeOfClock. This will be an integer that will be either 12 or 24. This tell the function how to print the time, either in military time (the parents type, call the parent method) or in normal type (12-hour) 11:30pm or 9:09am.

Fourth part:

Finally, show calls to instantiate two objects. One of the parent type, with the time set to 23:30:30 and one of the child type with the same time set. Show a call to printTime, using both objects.

Thanks in advance.

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

What are the qualities to look for in a prospective franchisee?

Answered: 1 week ago

Question

LO2 Compare three types of individual incentives.

Answered: 1 week ago