Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ Program to: 0). Create a file called Time.dat that contains: Seconds, Minutes and Hours. 1). Create a class called Clock. 2). Add

Write a C++ Program to:

0). Create a file called Time.dat that contains:

Seconds, Minutes and Hours.

1). Create a class called Clock.

2). Add functions: Tick(), Print(), and SetTime(int secs, int mins, int hours), seconds, minutes, hours

3). Tick() should be made into a pure virtual function.

4). Implement the functions.

5). Create a new class FunctioningClock which is a subclass of Clock.

6). FunctionalClock should implement the pure functions in the Clock class, and tick() should increment the time by one second. Aslo make sure to adjust the times appropriately with boundaries of seconds, minutes and hours in a 24 hour day.

7). Create another class called AlarmC which extends FunctioningClock.

8). It will extend the FunctioningClock but in an alarm clock manner. Whenvever an AlarmC ticks and reaches its alarm time, an Alarm! Message should be printed along with the current time.

9). Implement: checkAlarm() and tick(). (Do NOT copy and paste code from FunctioningClock) Reflect on how you could make the AlarmClock tick and update its minutes and hours correctly without rewriting all the code from FunctioningClocl.tick().

10). Both of the clocks will use the same starting times, but they extend the data in Time.dat with the alarm time (3 more numbers) for the AlarmC as well.

Seconds, minutes, hours, alarmSeconds, alarmMinutes, alarmHours.

11). Main should instantiate both types of the clock. Print both the Clock objects and invoke tick() 100,000 times on both the Clock objects. Print both Clock objects.

12). Create a new TimerClock which extends Clock.

13). It is just like FunctioningClock however, whenever tick is invoked it goes back one second. (So if initial time is 0:0:0 and tick() is invoked, the new time becomes 23:59:59

14). Implement tick()

15). Main() function should instantiate each of the 3 Clock classes. All Clocks should use the same starting time. The AlarmC time should be read from the Time.dat file.

16). Print all 3 Clock objects and invoke tick() 100,000 times on all Clock objects. Then, print all the Clock objects again.

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What information remains to be obtained?

Answered: 1 week ago