Question: In C++ Here's the base code for the driver, header, and implementation files: DRIVER #include #include Clock.h #include using namespace std; int main() { Clock

In C++

In C++ Here's the base code for the driver, header, and implementation

Here's the base code for the driver, header, and implementation files:

DRIVER

#include  #include "Clock.h" #include  using namespace std; int main() {  Clock c1;   cout   cout   cout   cout   c1.setHour(5);  c1.setMinute(9);  c1.setSecond(23);  c1.printTime(false);  // 17:09:23  c1.tick();  c1.printTime(false);  for (int i = 0; i   c1.tick();  c1.printTime(false);  Sleep(1000);  system("cls");  }  return 0; } 

HEADER

#ifndef CLOCK_H #define CLOCK_H class Clock { private:  int hour, minute, second;  bool isMorning; public:  Clock(int h = 12, int m = 0, int s = 0, bool isM = true);  void setHour(int h);  void setMinute(int m);  void setSecond(int s);  void setIsMorning(bool isM);  int getHour();  int getMinute();  int getSecond();  bool getIsMorning();  void printTime(bool twelveHourFormat);  void tick(); #endif };

IMPLEMENTATION

#include "Clock.h" #include  using namespace std; Clock::Clock(int h, int m, int s, bool isM) {  setHour(h);  setMinute(m);  setSecond(s);  setIsMorning(isM); } void Clock::setHour(int h) {  if (h   h = 1;  if (h >= 13)  h = 12;  hour = h; } void Clock::setMinute(int m) {  if (m   m = 0;  if (m >= 60)  m = 59;  minute = m; } void Clock::setSecond(int s) {  if (s   s = 0;  if (s >= 60)  s = 59;  second = s; } void Clock::setIsMorning(bool isM) {  isMorning = isM; } int Clock::getHour() {  return hour; } int Clock::getMinute() {  return minute; } int Clock::getSecond() {  return second; } bool Clock::getIsMorning() {  return isMorning; }
void Clock::printTime(bool twelveHourFormat) {  // Insert code here  cout  } void Clock::tick() {  // Insert code here  setSecond(second + 1); }  

Please provide complete code for implementation file and any other changes for the other two files.

Implement a class called Clock with fields hour, minute, second of type int and isMorning of type bool. Include a constructor to initialize the Clock along with appropriate getters and setters for the fields. The constructor should have default parameters values of 12, 0,0 and true, respectively, for the parameters corresponding to hour, minute, second and isMorning. Also include a void method tick that advances the clock by one second. Of course the clock should eventually roll back around to to 12:00:00 AM. Finally, include a method printTime() that outputs the current time e.g. 12:34:56AM. printTime should take a parameter twelveHourFormat of type bool. (If called with true then 12 hour format will be used, otherwise 24 hour format will be used.) Code Clock.h, Clock.cpp and a driver to test your code. Be sure your driver calls all of the methods at least once

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!