Question: Homework Assignment # 2 Classes and Objects Problem: Implement a class named Time. The class should contain: The data fields for hour, minute, and second

Homework Assignment #2
Classes and Objects
Problem:
Implement a class named Time. The class should contain:
The data fields for hour, minute, and second that represent a time.
A no-argument constructor that creates a Time object for the current time. (The values of the data fields will represent the current time.)
A constructor that constructs a Time object with a specified elapsed time since midnight, January 1,2000, in milliseconds. (The values of the data fields will represent this time.)
A constructor that constructs a Time object with the specified hour, minute, and second.
Three getter methods for the data fields hour, minute, and second, respectively.
A method named setTime(long elapseTime) that sets a new time for the object using the elapsed time. For example, if the elapsed time is 555550000 milliseconds, the hour is 10, the minute is 19 and the second is 10.
Then implement a test class named Driver. In this test class create two Time objects (using new Time() and new Time(555550000)) and displays their hour, minute, and second in the format
hour:minute:second
e.g.10:19:10
Hint: For the no-argument constructor, the current time can be obtained using System.currentTimeMillis(). The other two constructors will extract the hour, minute, and second from the elapsed time.
Comments and Style
Comment your code.
At the top of the program include your name, a brief description of the problems you are solving and what it does and the due date.
Note: Follow the instructions given.
All blocks must be indented consistently and correctly. Blocks are delimited by opening and closing curly braces.
Opening and closing curly braces must be aligned consistently
Variable names should convey meaning
Requirements
Prompt the user for the inputs and store the values in variables
You must include all the inputs and outputs listed above and perform the calculations correctly
Make the output look attractive. It should be better than the sample run above.
The program should display your name
Hints:
Solve the problem in pieces.
Start early.
Deliverables:
Submit the following item(s):
Name your Java project as LastnameFirstname_HW02 export then upload the .zip file into the appropriate section under Assignment in D2L.(You must submit the program regardless of whether it complete or incomplete, correct, or incorrect)
Note: Strictly follow the export instructions to submit your assignment.

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!