Create a class that represents a Clock. The Clock class has 3 variables: amPm, h
ID: 3567386 • Letter: C
Question
- Create a class that represents a Clock. The Clock class has 3 variables: amPm, hour, minute. In addition the Clock as the following functions:
- Default constructor that sets amPm to
Explanation / Answer
#include #include using namespace std; class Clock { private: int mHours; int mMinutes; int mSeconds; public: Clock(); Clock(int); Clock(int, int); Clock(int, int, int); int getHours(); {return mHours;} int getMinutes(); {return mMinutes;} int getSeconds(); {return mSeconds;} void setHours(int hourValue) { if(hourValue > 0 && hourValue < 13) { mHours = hourValue; }else if(hourValue12) { mHours = 12; } } void setMinutes(int minuteValue) { if(minuteValue > 0 && minuteValue < 60) { mMinutes = minuteValue; }else if(minuteValue < 0) { mMinutes = 0; }else if( minuteValue > 59) { mMinutes = 59; } } void setSecond(int secondValue) { if (secondValue > 0 && secondValue < 60) { mSeconds = secondValue; }else if(secondValue < 0) { mSeconds = 0; }else if(secondValue > 59) { mSeconds = 59; } } bool isMorning(); bool isAfternoon(); bool isEvening(); void printTimeMessage(int, int, int); void tick(); friend ostream &operatorRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.