Design two exception classes for checking height

Table of contents

programming

program analysis

Series of articles


Design two exception classes for checking height. TooShortException is generated when the input height is lower than 170, and TooTallException is generated when the input height is higher than 180. Write a check class, in which there is a method for checking height. If the height meets the conditions, it returns True. Otherwise, one of the above two exceptions will occur depending on the situation. Write a program to test the above content requirements.

programming

HeightChecker class:

class TooShortException extends Exception {
    public TooShortException(String message) {
        super(message);
    }
}

class TooTallException exte

Guess you like

Origin blog.csdn.net/m0_68111267/article/details/134028436