Explore BrainMass
Share

Explore BrainMass

    Returning Error Indicators from Methods - Java

    This content was COPIED 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 October 9, 2019, 7:42 pm ad1c9bdddf
    https://brainmass.com/computer-science/java/returning-error-indicators-methods-java-126407

    Attachments

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

    $2.19