Question: JAVA All variable names must be preceded by yourInitials. I would name my Scanner variable rnInput and use rnHour, rnMinute, and rnSecond, rnSeconds as other

JAVA

All variable names must be preceded by yourInitials. I would name my Scanner variable rnInput and use rnHour, rnMinute, and rnSecond, rnSeconds as other variable names. Your grade will not exceed 70 if variables do not have your initials.

Define a class named YourInitialsTime for encapsulating a time. The class implements Comparble, Cloneable{

The class contains the following:

1. A data field of the long time that stores the elapsed time since midnight, Jan 1, 1970

2. A no-arg constructor that constructs a Time for the current time.

3. A constructor with the specified hour, minute, and second to create a Time.

4. A constructor with the specified elapsed time since midnight, Jan 1, 1970.

5. The getHour() method that returns the current hour in the range 0-23.

6. The getMinute() method that returns the current minute in the range 0-59.

7. The getSecond() method that returns the current second in the range 0-59. 8. The getSeconds() method that returns the elapsed total seconds.

9. The toString() method that returns a string such as "1 hour 2 minutes 1 second" and "14 hours 21 minutes 1 second".

10. Implement the Comparable interface to compare this Time with another one based on their elapse seconds. The compareTo method returns the difference between this objects elapse seconds and the anothers.

11. Implement the Cloneable interface to clone a Time object.

Write a test class named YourInitialsTest(RNTest) that produces the following sample run:

Enter time1 (hour minute second): 331 34 674

19 hours 45 minutes 14 seconds

Elapsed seconds in time1: 1194314

Enter time2 (elapsed time): 93889345

16 hours 22 minutes 25 seconds

Elapsed seconds in time2: 93889345

time1.compareTo(time2)? -92695031

time3 is created as a clone of time1

time1.compareTo(time3)? 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!