Question: Create a new subclass named Clock that inherits from your TimeType class. Like the TimeType class, the Clock class will be used to represent a
Create a new subclass named Clock that inherits from your TimeType class.
Like the TimeType class, the Clock class will be used to represent a hour clock with the addition of three private integer attributes: month, day, and year.
Clock should contain the following methods:
constructor Instantiates a Clock object and sets the date to and the time to ::
You should create a List class variable of elements that you will reference to determine if the given day is valid for the current month. The days in each month are: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec You should use the leapYear method to determine if Feb. should contains or days. You will use this list to determine if a particular day is valid for a given month. It will be used by the methods below.
leapyearyear a class method that returns True if the parameter is a leap year, otherwise returns False. A year is a leap year if it is divisible by but not by except if divisible by Said another way: Any year that is evenly divisible by is a leap year, except century years that are not evenly divisible by
setClock Takes integer parameters representing hrsmins, secs mon, dy yr and sets the time and date in the object according to the parameters and returns True provided all parameters are valid, otherwise does nothing and returns False.
increaseDay Increases the day by one. This method should also adjust month and year if necessary.
decreaseDay Decreases the day by one. This method should also adjust month and year if necessary.
increaseSecond Increases the second by one. This method should also adjust the minutes, hours, day, month and year if necessary.
decreaseSecond Decreases the second by one. This method should also adjust the minutes, hours, day, month and year if necessary.
str Returns the time in the format mmddyyyy HH:MM:SS AMPM
Notes:
All methods should handle leap years correctly. It is easiest to call the leapyear method at the beginning of the increase, decrease, and set methods and adjust the number of days in Feb before proceeding.
Write your own client to test the implementation of your Clock class. Make sure you test all methods. For example, increase and decrease the seconds that roll forward and backward from one year to the next, and from February to March in both a leap and nonleapyear.
in python lang. please
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
