Explore BrainMass

Returning Error Indicators from Methods - Java

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

Modify the set methods in class Time2 of Fig. 8.5 to return appropriate error values if an attempt is made to set one of the instance variables hour, minute or second of an object of class Time to an invalid value. [Hint: Use boolean return types on each method.] Write a program that tests these new set methods and outputs error messages when incorrect values are supplied.

Please see attachments for full problem details.

© BrainMass Inc. brainmass.com December 19, 2018, 11:39 pm ad1c9bdddf


Solution Preview

In order to test if user supplies a wrong value for hour, minute and second three private boolean variables were introduced in ...

Solution Summary

The solution illustrates how to return error conditions from Java methods using an example (see attachment).