try { System.out.println("Injection bank: " + bank); PrintWriter out = response.getWriter(); String partialName = request.getParameter("partialName"); out.println("
Customers by partial Name: " + partialName + "
");
Customer[] customers = bank.getCustomers(partialName);
for (Customer cust : customers) {
out.println("
" + cust.getSsn() + " " + cust.getTitle() + " " + cust.getFirstName() + " " + cust.getLastName());
}
Customer cust1 = bank.getCustomer("222-22-2222");
out.println("
Customer: " + cust1.getSsn() + " " + cust1.getTitle() + " " + cust1.getFirstName() + " " + cust1.getLastName());
Account[] accts = bank.getAccounts(cust1.getSsn());
out.println("
Customer: " + cust1.getSsn() + " has " + accts.length + " accounts");
Account acct = bank.getAccount("002-222002");
out.println("
Account: " + acct.getId() + " balance " + acct.getBalance()); out.println("
Transactions of account: " + acct.getId()); Transaction[] trans = bank.getTransactions("002-222002"); out.println("
Type | Time | Amount |
---|---|---|
" + t.getTransType() + " | " + t.getTransTime() + " | " + t.getAmount() + " |
Add a customer: " + newssn);
Customer custnew = new Customer();
custnew.setSsn(newssn);
custnew.setTitle("Mrs");
custnew.setFirstName("Julia");
custnew.setLastName("Roberts");
bank.addCustomer(custnew);
Customer cust2 = bank.getCustomer(newssn);
out.println("
Customer: " + cust2.getSsn() + " " + cust2.getTitle() + " " + cust2.getFirstName() + " " + cust2.getLastName());
out.println("
Open two accounts for customer: " + newssn);
String id1 = bank.openAccount(newssn);
String id2 = bank.openAccount(newssn);
out.println("
New accounts: " + id1 + " " + id2);
Account[] acctnew = bank.getAccounts(newssn);
out.println("
Customer: " + newssn + " has " + acctnew.length +
" accounts");
Account acct1 = bank.getAccount(id1);
out.println("
Account: " + id1 + " balance " + acct1.getBalance());
out.println("
Deposit and withdraw from account: " + id1);
bank.deposit(id1, new java.math.BigDecimal("777.77"));
bank.withdraw(id1, new java.math.BigDecimal("111.11"));
acct1 = bank.getAccount(id1);
out.println("
Account: " + id1 + " balance " + acct1.getBalance());
trans = bank.getTransactions(id1);
out.println("
Type | Time | Amount |
---|---|---|
" + t.getTransType() + " | " + t.getTransTime() + " | " + t.getAmount() + " |
Close the account: " + id1); bank.closeAccount(newssn, id1); out.println("
Update the customer: " + newssn);
bank.updateCustomer(newssn, "Mr", "Julius", "Roberto");
cust2 = bank.getCustomer(newssn);
out.println("
Customer: " + cust2.getSsn() + " " + cust2.getTitle() + " " + cust2.getFirstName() + " " + cust2.getLastName());
out.println("
Delete the customer: " + newssn); bank.deleteCustomer(newssn); out.println("
Retrieve non existing customer: ");
Customer cust3 = bank.getCustomer("zzz-zz-zzzz");
out.println("
customer: " + cust3);
out.println("
End"); } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); }