Question: in Python Create a class that will hold the information about a clock, called Clock. You need to keep minutes, hours and seconds in military

in Python

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.

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

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.

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

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!