Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

9:147 0...Xythos.s3.us-east-1.amazonaws.com Due Dieu 16.2020 1) Write a Java class Clock for dealing with the day time represented by hours, minutes, and seconds Your class

image text in transcribed
9:147 0...Xythos.s3.us-east-1.amazonaws.com Due Dieu 16.2020 1) Write a Java class Clock for dealing with the day time represented by hours, minutes, and seconds Your class must have the following features: Three instance variables for the hours range- 23), minutes (range 0 - 59), and seconds (range 0 Three constructors: default (with no parameters passed; should initialize the represented time to 12-0-0) a constructor with three parameters hours, a constructor with one parameter: the value of time in seconds since midnight it should be converted into the time value in hours, minutes and seconds) Instance methods a set-method method set Clock() with one parameter seconds since midnight to be converted into the time value in hours, minutes, and seconds as above). methods getHours().getMinutes().getSeconds with no parameters that return the corresponding methods setHours), setMinutes), setSeconds ith one parameter each that set up the method tick) with no parameters that increments the time stored in a lock object by one second method addClock) accepting an object of type Clock as a parameter. The method should add the time represented by the parameter ass to the Add an instance method toString() with me parameters to your class.toString) must return a String representation of the Clock object in the form (hh:mm:ss)", for example 03.02:34) Add an instance method tick Down() which one second stored in a God object by Add an instance method Subtract Clock that takes one Clock parameter and returns the difference between the time represented in the current Clock parameter. Difference of time should be returned as an clock object. 2) Write a separate class Clock Demo with a man method. The program should: instantiate a Clock object firstClock using one Integer seconds since midnight obtained from the keyboard. .tick the clock ten times by applying its method and print out the time or each sick Extend your code by appending to it instructions instantiating a Clock object secondClock by using three integers (hours, minutes, seconds) read from the keyboard Then tick the dock of the secondClock ten times, printing the time after each tick. Add the secondClock time in first Clock by calling method addClock. Print both clock objects calling toString method Create a reference third Clock that should reference to object of difference of first Clock and secondClock by calling the method subtractClock()

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

Students also viewed these Databases questions

Question

What would you do about the verbal homophobic and racial insults?

Answered: 1 week ago