Lesson 6
Objectives
Understand collections:
- Lists
- Sets
- Maps
Documentation
Exercises
Exercise 1
For the class diagram above:
- implement BankAccount class;
- overwrite equals and hashCode methods for BankAccount in order to provide a correct way for comparing object;
- create some BankAccount objects and demonstrate the equals method is working correctly.
Exercise 2
For the class diagram above:
- implement the program according to the class diagram;
- use an ArrayList for storing the BankAccount objects;
- implement a printAccounts which will print a sorted list (by balance) of all accounts;
- implement a printAccounts with range which will display all accounts between min range and max range values.
- get in test main method all bank accounts (using getAllAccounts() method) and sort them alphabetically by owner field.
Exercise 3
Create a new version for the application from previous exercise (with the same functionality) and replace ArrayList with a TreeSet.