7. Exceptions and assertions
Review the presentation Exceptions and safeguards
Tasks
- Explore the jtm.activity07 package
- Create the class SimpleCalcException as a subclass of Exception.
- Implement the following constructors for this class:
- SimpleCalcException(String string)
- SimpleCalcException(String string, Throwable cause)
Implement basic arithmetic operations for the SimpleCalc class with int numbers in the range [-10..+10] (inclusive) to pass unit tests
Notes
- The input range is checked using safeguards. Therefore, if they are disabled, any int value can be input
- The output is always checked and an exception is thrown if the value is outside the allowed range
- Only SimpleCalcExceptions can be thrown. AssertionErrors etc. must be caught and wrapped in SimpleCalcExceptions