Purchase Solution

A Java Class for Time

Not what you're looking for?

Ask Custom Question

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:

Attachments
Purchase this Solution

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.

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() ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Javscript Basics

Quiz on basics of javascript programming language.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C++ Operators

This quiz tests a student's knowledge about C++ operators.