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 represent 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 second 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. Use inheritance and abstraction and (polymorphism if required) in Java Programming. Also make its main class to call the methods properly and give the correct output. Also use String.format(String obj, args) in toString to return the formatted String.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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 represent 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 second 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.

Use inheritance and abstraction and (polymorphism if required) in Java Programming. Also make its main class to call the methods properly and give the correct output. Also use String.format(String obj, args) in toString to return the formatted String.

Expert Solution
steps

Step by step

Solved in 6 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY