This project is designed to help students practice Java programming, object-oriented principles, and basic testing with JUnit. The project consists of a simple banking system where students need to complete certain methods and make the provided test functions work correctly.
The project contains the following main classes:
- Bank: Manages clients and their accounts.
- BankAccount: Represents an individual bank account with basic balance operations.
- Client: Represents a bank client with personal details and a list of accounts.
- BankTest: Contains JUnit tests to verify the functionality of the Bank system.
Each class has incomplete methods that need to be implemented.
-
Open each class file and implement the unfinished methods marked with comments. The goal is to create a fully functional banking system where clients can log in, manage accounts, and perform transactions.
-
Pay attention to the requirements provided in the comments within each method. For example:
- In
Bank
, ensure clients can only log in with valid credentials. - In
BankAccount
, ensure only valid transactions (e.g., non-negative balances) are allowed. - In
Client
, handle edge cases for adding or removing accounts.
- In
After completing the methods, run the tests in BankTest.java
to verify your implementation. Make sure the tests pass successfully.
Follow these steps to open the project in IntelliJ IDEA and set up JUnit for testing.
- Open IntelliJ IDEA.
- Select Open from the welcome screen.
- Navigate to the folder containing this project and open it.
- If needed select an SDK
To run the tests, JUnit must be added as a library.
- Go to the BankTest.java file in the IDE
- Expand the imported modules
- Place the cursor on junit and press Alt + Enter
- Select 'Add 'JUnit4' to class path', then select OK.
- Open
BankTest.java
. - Right-click anywhere in the code and select Run 'BankTest' to execute all test cases.
- Check the test results. Any failed tests indicate methods that need further debugging or completion.
- If you encounter issues with JUnit not being recognized, double-check that the library is correctly added to the project.
- Refer to the comments within each method for guidance on implementing the logic required for the tests to pass.
This exercise helps you develop and test your coding skills, along with learning to set up and use JUnit in a Java project. Good luck, and happy coding!