A simple Java console calculator application with robust input handling, error management, and modular design. This project demonstrates best practices in Java structure, testing, and documentation.
src/
main/Main.java # Entry point for the calculator application
classes/Kalkulators.java # Calculator logic and arithmetic operations
interfaces/KalkInterface.java # Functional interface for result formatting
interfaces/MathInterface.java # Interface for arithmetic operations
test/
AppTest.java # Tests for main application logic
KalkulatorsTest.java # Tests for Kalkulators arithmetic and getters/setters
KalkulatorsInterfaceTest.java # Tests for Kalkulators interface and constants
run-tests.sh # Script to compile and run all tests
lib/ # JUnit and Lombok libraries
- Entry point for the calculator app
- Interacts with the user via the console
- Prompts for operation (
+
,-
,*
) and two integer operands - Validates input and limits allowed mistakes before terminating
- Delegates calculation logic to the
Kalkulators
class
- Implements a simple calculator with addition, subtraction, and multiplication
- Uses
MathInterface
for multiplication and default subtraction - Uses
KalkInterface
for result formatting via a lambda expression - Annotated with Lombok for getters, setters, and no-args constructor
- Constant
ATLAUTO_KLUDU_SKAITS
limits allowed input errors
- Functional interface for formatting calculation results as strings
- Interface for arithmetic operations
- Provides default implementation for subtraction
- Simulates user input and captures output
- Verifies addition, multiplication, and invalid operation scenarios
- Verifies correctness of arithmetic operations and getter/setter methods
- Verifies result formatting and constant value
./run-tests.sh
- Cleans, compiles, and runs all tests with preview features enabled
java --enable-preview -cp bin main.Main
- Java 24 (for preview features)
- JUnit 5 (standalone jar in
lib/
) - Lombok (jar in
lib/
)
Arturs
This README was generated from Javadoc comments in the source files for clarity and completeness.