Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program with the following requirements and conditions: Java Programming In your program you're supposed to be able to create different kind of clocks.

Write a program with the following requirements and conditions: Java Programming 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 displayCurrentTime(). 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 aPendulumClock, 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 calledsetTime, 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)

Extra Credit: Create and submit another UML Diagram for Exercise 2 (+10 points)

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Discuss the states of accounting

Answered: 1 week ago