Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write code in Java with explanations so, I can understand. Thank you! Write a program with the following requirements and conditions In your program

Please write code in Java with explanations so, I can understand.

Thank you!

image text in transcribed

Write a program with the following requirements and conditions In your program you're supposed to be able to create different kind of clocks. You will need a base class called Clock. This class should have a parameter (or parameters) to save the current time. This object should also have a function called displayCurrentTime0. When this function is called, it should output the current time to the console. The class also should have a String parameter called "Make" Next, you will create three subclasses that inherit from Clock, those three classes are Watch, PendulumClock, and DigitalClock. The Watch class should have a private parameter called alarm, which can hold a specific time to save an alarm. It also should provide a public get and set function for this parameter. The PendulumClock should have a function called windUp). When this function is called, it should set an internal parameter to currentTime +24h. When the user requests the time from a PendulumClock, only if the 24h haven't passed since the last wind-up, the current time should be displayed, otherwise a message should be output that says: "Please wind up the clock." (hint: you will need to override the function from the base class) The DigitalClock should be able to be manually set. That means it should have a function called setTime, which will set the time to whatever the user inputs and passes to the function, and when asked again what the current time is it should accurately keep track of timekeeping based on the new time set. (hint: you might want to save the time difference in a private property if the time is manually set, so anytime the time is requested, you will know how to calculate the difference from the current time upon request) Write a program with the following requirements and conditions In your program you're supposed to be able to create different kind of clocks. You will need a base class called Clock. This class should have a parameter (or parameters) to save the current time. This object should also have a function called displayCurrentTime0. When this function is called, it should output the current time to the console. The class also should have a String parameter called "Make" Next, you will create three subclasses that inherit from Clock, those three classes are Watch, PendulumClock, and DigitalClock. The Watch class should have a private parameter called alarm, which can hold a specific time to save an alarm. It also should provide a public get and set function for this parameter. The PendulumClock should have a function called windUp). When this function is called, it should set an internal parameter to currentTime +24h. When the user requests the time from a PendulumClock, only if the 24h haven't passed since the last wind-up, the current time should be displayed, otherwise a message should be output that says: "Please wind up the clock." (hint: you will need to override the function from the base class) The DigitalClock should be able to be manually set. That means it should have a function called setTime, which will set the time to whatever the user inputs and passes to the function, and when asked again what the current time is it should accurately keep track of timekeeping based on the new time set. (hint: you might want to save the time difference in a private property if the time is manually set, so anytime the time is requested, you will know how to calculate the difference from the current time upon request)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago