Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create 3 classes: 1. SimpleClock - two member variables - time and hour a. 3 con

ID: 3534881 • Letter: C

Question

Create 3 classes:

1. SimpleClock - two member variables - time and hour

a. 3 constructors

i. no arguments - represents midnight, 00:00

ii. one argument - hour

iii. two arguments - hour and minutes

b. method named getString() - use "virtual" when defining it - returns a string in the format 00:00

c. method tick() - use "virtual" when defining it - returns nothing - adds one to the minute

2. TwelveHourClock - sublcass of SimpleClock

a. uses hours and minutes from SimpleClock

b. same 3 constructors listed for SimpleClock

c. define the method getAMPM() - returns the string "AM" if thehours is less than 12, otherwise PM

d. Override getString() method in the parent class

i. return a string in a 12-hour format 00:00 AM/PM

ii. printed hour should be in the range to 1-12

3. AccurateClock - represents time for a 12-hour clock with seconds

a. Subclass of TwelveHourClock

b. uses hour and minutes variables from SimpleClock

c. additional member value seconds (0 - 59)

d. 4 constructors

i. one with no arguments - represents midnight

ii. one with one argument - hour

iii. one with two arguments - hour and minutes

iii. one with three arguments - hour, minutes, seconds

e. override tick() in parent class - returns nothing - adds one to the second

f. override the getString() method in parent class - return a string in the format 00:00:00 AM/PM


Functions:

1. voidprintCurrentTime(SimpleClock &clock)

a. print message including "the current time is"

b. use the clock's getString () method


Main:

-create 6 objects

1. SimpleClock object that represents midnight - print using printCurrentTime()

2. SimpleClock object that represent 20:56

a. write a loop that calls the object's tick() method each time through the loop, 10 times total. After each tick, print the time using

printCurrentTime()

3. TwelveHourClock object that represents 9:00AM - print using printCurrentTime()

4. TwelveHourClock object that represents 11:56PM

a. write a loop that calls the object's tick() method each time through the loop, 10 times total. After each tick, print the time.

5. AccurateClock that represents 07:45:03PM - print using printCurrentTime()

6. AccurateClock represents 12:59:58AM

a. write a loope that calls the object's tick() method each time through the loop, 10 times total. After each tick, print the time.


Additional notes:

1. Wherever you are asked to print the time in main(), use the printCurrentTime() function.

2. All 3 classes store the time in 24-hour format. therefore hours (0-23). It is the getSTring() method in each class that changes the way the times are string are viewed. getSTring() should never modify member variables, only use them to build a string

3. The tick() method should handle wrap-around. If you have a SimpleClock that represents 10:59 and you call tick(). You should see 11:00 when printed, not 10:60.

4. The constructors should set a field to 0 if the value passed in outside the legal range. for example, if you try to set the seconds to 100 in an AccurateClock that is not in the legal range 0 to 59. In that case, the seconds would be set to 0.


PLEASE HELP!!!!!!!!!



Explanation / Answer

Please rate with 5 stars :)


Here is how to approach this: