Legacy - 4
Summary by Bito
This pull request introduces a new Calculator class in test2.java, implementing basic arithmetic operations including add, subtract, multiply, and divide methods, along with a demonstration main method. Additionally, it enhances the divide method with a check to throw an exception for division by zero.
Detailed Changes
- Adds a Calculator class with add, subtract, multiply, and divide methods in test2.java.
- Introduces a main method that creates a Calculator instance and performs sample operations, including some with intentional errors like type mismatches and division by zero.
- The divide method is implemented to return a double type for handling decimal results from integer division.
- Adds a check in the divide method to throw IllegalArgumentException when the divisor is zero.
Edited by gitlab_custom_domain