hi i was wondering on how to add my own exception to the withdrawl method.
import java.util.ArrayList; import java.util.List; public class BankManager implements _BankManager { Storage store; public BankManager() { store = new ArrayListStorage(); } public BankAccountOutputVO ViewAccountSummary(String accountNumber) throws AccountDoesNotExist { BankAccountOutputVO bao = null; int accountNum = Integer.parseInt(accountNumber); for (BankAccount acc : store.getList()) { if (acc == null) { //System.out.println("Account Does not exists"); throw new AccountDoesNotExist(); } if (acc.getAccountNumber() == accountNum) { store.getList(); bao = BankAccount.convertBAO(acc); } else { throw new AccountDoesNotExist(); } } return bao; } public BankAccountOutputVO closeAcount(String accountNumber) { BankAccountOutputVO bao = null; int accountNum = Integer.parseInt(accountNumber); for (BankAccount acc : store.getList()) { if (acc == null) { // throw new AccountDoesNotExist(); } if (acc.getAccountNumber() == accountNum) { if (acc.balance == 0) { store.getList().remove(acc); bao = BankAccount.convertBAO(acc); } else if (acc.getAccountNumber() == accountNum) { bao = BankAccount.convertBAO(acc); break; } } } return bao; } public BankAccountOutputVO createNewCurrentAccount(String name, double amount, double overdraftLimit) { BankAccountOutputVO bao = null; BankAccount acc = new CurrentAccount(name, amount, overdraftLimit); store.getList().add(acc); bao = BankAccount.convertBAO(acc); return bao; } public BankAccountOutputVO createNewSavingsAccount(String name, double amount) { BankAccountOutputVO bao = null; BankAccount acc = new SavingAccount(name, amount, amount); store.getList().add(acc); bao = BankAccount.convertBAO(acc); return bao; } public List<BankAccountOutputVO> listAllAccounts() { ArrayList<BankAccountOutputVO> bao = new ArrayList<BankAccountOutputVO>(); for (BankAccount acc : store.getList()) { bao.add(BankAccount.convertBAO(acc)); } return bao; } public BankAccountOutputVO makeDeposit(String accountNumber, double amount) throws AccountDoesNotExist { BankAccountOutputVO bao = null; int accountNum = Integer.parseInt(accountNumber); for (BankAccount acc : store.getList()) { if (acc.getAccountNumber() == accountNum) { acc.setdeposit(amount); store.deposit(acc); bao = BankAccount.convertBAO(acc); } else{ throw new AccountDoesNotExist(); } } return bao; } public BankAccountOutputVO makeWithdrawal(String accountNumber, double amount) { BankAccountOutputVO bao = null; int accountNum = Integer.parseInt(accountNumber); for (BankAccount acc : store.getList()) { if (acc.getAccountNumber() == accountNum) { if ((acc.getAccountType().equals("Saving Account")) && (acc.balance >= amount)) { acc.setwithdrawl(amount); store.withdraw(acc); bao = BankAccount.convertBAO(acc); break; } else if ((acc.getAccountType().equals("Current Account")) && ((acc.balance + acc.overdraftLimit) >= amount)) { acc.setwithdrawl(amount); store.withdraw(acc); bao = BankAccount.convertBAO(acc); break; } else { bao = BankAccount.convertBAO(acc); break; } } if (acc == null) { System.out.println("Account Does not avalible"); throw new NullPointerException(); } } return bao; } } /highlight highlight=java class MakeWithdrawalAction implements _DisplayAction { public void execute(UserInputVO input, _BankManager bank, _DisplayManager dm) { BankAccountOutputVO output = null; output = bank.makeWithdrawal(input .getAccountNumber(), input.getAmount()); dm.AccountChange(output.getAccountNumber(), output.getName(), output.getBalance(), output.getOverdraft()); } }