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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education