Question: Modify a Class Implementation Tips Accomplish your task incrementally. In Time 2 o Create a new instance variable called totalSeconds to keep track of the

Modify a Class Implementation Tips
Accomplish your task incrementally.
In Time2
o Create a new instance variable called totalSeconds to keep track of the total number of
seconds from midnight.
o Now start converting the getters and setters starting with getHour() and setHour().
Since you need getHour() to complete setHour() start with getHour(). getHour() just
returns totalSeconds /60/60. setHour() subtracts out the current value for the hour
and then adds the new value. setHour() looks like the following:
o You should now be able to delete the instance variable hour and when you run
Time2Test.java the output should be exactly the same as it was before you made the
changes to getHour() and setHour().
o Now do the same thing to getMinute() and setMinute() coming up with the correct
formulas to work with minutes instead of hours. Then delete the instance variable
minute.
o Finally, convert getSecond() and setSecond() and when you are done delete the instance
variable second.
In Time2Test.java the only change you are allowed to make is to add a statement at the
beginning of main() to output your name and lab number.

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 Programming Questions!