Explore BrainMass

Explore BrainMass

    A Java Class for Time

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Modify class Time2 of Fig. 8.5 to include a tick method that increments the time stored in a Time2 object by one second. Provide method incrementMinute to increment the minute and method incrementHour to increment the hour. The Time2 object should always remain in a consistent state. Write a program that tests the tick method, the increment-Minute method and the incrementHour method to ensure that they work correctly. Be sure to test the following cases:

    © BrainMass Inc. brainmass.com November 24, 2021, 1:05 pm ad1c9bdddf
    https://brainmass.com/computer-science/java/a-java-class-for-time-139426

    Attachments

    Solution Preview

    There are two files: Time2.java is the .java class to handle second ticks and the Time2Test.java that tests the The set methods incorporate error handling, therefore simply adding 1 to the previous values of second/minute/hour works. You can add the following four methods. Notice how incrementSecond() ...

    Solution Summary

    Solution includes two files: Time2.java is the .java class to handle second ticks and the Time2Test.java that tests the The set methods incorporate error handling, therefore simply adding 1 to the previous values of second/minute/hour works. You can add the following four methods. Notice how incrementSecond() triggers incrementMinute() when seconds exceed 59 and incrementMinute() triggers incrementHour when minute exceeds 59.

    $2.49

    ADVERTISEMENT