Question
Create a class named Clock. The Clock class should have three attributes hour represents the time hour and should be a value between 0 and
Create a class named Clock. The Clock class should have three attributes hour represents the time hour and should be a value between 0 and 23 minute represents the time minute and should be a value between 0 and 59 second represents the time second and should be a value between 0 and 59
Methods should include: the constructor the appropriate accessors and mutators; be sure to include code in the mutators to make sure correct values are used increment method that increases second by 1; this should include code that will increase minute by 1 if second is greater than 59 and then change second back to 0. This should also be the same for minute to hour and hour back to 0. an __str__ to print the time in the format hh:mm:ss
Create a subclass of Clock called Alarm. Alarm should include the following attributes: alarmTime that is an object of the Clock class (if you cannot figure out how to do this, ask in class) alarmOn that is a Boolean value True means alarm is on, False means alarm is off an __str__ to print the alarmTime and alarmOn values
The following methods should be created: setAlarm this will use the Clock methods to set the alarmTime onOff to turn the alarm on or off Create a test program to set a Clock object and print the time and also set an alarmTime and print its values.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started