package lk.ac.pdn.ceit.fullstack; import java.util.HashMap; import java.util.Map; public class AccountManager { private Map accounts = new HashMap<>(); /* This is a called a constructor. It gets executed when an object of this class is created. */ public AccountManager() { // For testing, create some account objects. // In a real systems, account data will be in a storage system like a database. Account account = new Account(1, 10.0); accounts.put(account.getAccountNumber(), account); account = new Account(2, 20.0); accounts.put(account.getAccountNumber(), account); account = new Account(3, 10.0); accounts.put(account.getAccountNumber(), account); } public void withdraw(int accountId, double amount) { Account account = accounts.get(accountId); account.setBalance(account.getBalance() - amount); } public void deposit(int accountId, double amount) { Account account = accounts.get(accountId); account.setBalance(account.getBalance() + amount); } public double getBalance(int accountId) { return accounts.get(accountId).getBalance(); } }