An abstract class Clock has been provided with following instance variables hours mins secs This class has an abstract method tick(). The responsibility of this method is to represent the passage of 1 second but what time is reached after ticking depends upon whether the clock is 24 hrs or 12 hours.     You need to provide two subclasses namely Clock12 and Clock24 which reprent the 12 and 24 hours clock respectively. Override the tick() mehtod in each of these classes so that 1 tick increases the time by 1 secont and updates all values (hrs min and seconds accordingly). On 24 hours clock 1 tick increases 1 second but consider the situation if the current time was 10:59:59 then ticking once will make it 11:00:00. You will have to consider all situations. 1 second can mean just increment in the seconds value. But if the seconds become 60 then you need to make it 0 again and increment mins instead and so on. Also, after 23:59:59 the time becomes 00:00:00     On the 12 hours clock we will have to take an additional member am (boolean). If am is true then the 12 hours time is AM time otherwise its PM. Provide appropriate constructor for 12 hours clock to intialize all data members. Remember that in 12 hours clock the after 12:59:59 t AM The time becomes 01:00:00 PM. Similarly if originally its PM then it becomes AM.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

An abstract class Clock has been provided with following instance variables

  1. hours
  2. mins
  3. secs

This class has an abstract method tick(). The responsibility of this method is to represent the passage of 1 second but what time is reached after ticking depends upon whether the clock is 24 hrs or 12 hours.

 

 

You need to provide two subclasses namely Clock12 and Clock24 which reprent the 12 and 24 hours clock respectively. Override the tick() mehtod in each of these classes so that 1 tick increases the time by 1 secont and updates all values (hrs min and seconds accordingly).

On 24 hours clock 1 tick increases 1 second but consider the situation if the current time was 10:59:59 then ticking once will make it 11:00:00. You will have to consider all situations. 1 second can mean just increment in the seconds value. But if the seconds become 60 then you need to make it 0 again and increment mins instead and so on. Also, after 23:59:59 the time becomes 00:00:00

 

 

On the 12 hours clock we will have to take an additional member am (boolean). If am is true then the 12 hours time is AM time otherwise its PM. Provide appropriate constructor for 12 hours clock to intialize all data members. Remember that in 12 hours clock the after 12:59:59 t AM The time becomes 01:00:00 PM. Similarly if originally its PM then it becomes AM.

 

 

Override the toString method for the 12 hours clock.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,