📄 accounttest.java
字号:
/* * * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */import java.util.*;import com.sun.ebank.ejb.account.*;import com.sun.ebank.ejb.exception.*;import com.sun.ebank.util.*;import java.rmi.RemoteException;public class AccountTest { private AccountController accountController; public AccountTest(AccountController accountController) { this.accountController = accountController; runTests(); } private void runTests() { try { // create a new account String customerId = "101"; String accountId = accountController.createAccount(customerId, "Checking", "Mary's acct", 220.00, 10.00, 100.00, new Date()); System.out.println(accountId); System.out.println(); // remove an account accountController.removeAccount("5004"); // add a customer to an account accountController.addCustomerToAccount("103","5001"); // remove a customer from an account accountController.removeCustomerFromAccount("104","5001"); // get account details by accountId AccountDetails ad = accountController.getDetails("5001"); DisplayDetails.print(ad); System.out.println(); // get account details by customerId // (get all accounts for a given customer) ArrayList accountList = accountController.getAccountsOfCustomer("103"); printArray(accountList); System.out.println(); // change account type accountController.setType("Checking", "5001"); } catch (RemoteException ex) { System.err.println ("Caught a RemoteException. " + ex.getMessage()); } catch (AccountNotFoundException ex) { System.err.println ("Caught a AccountNotFoundException. " + ex.getMessage()); } catch (CustomerRequiredException ex) { System.err.println ("Caught a CustomerRequiredException. " + ex.getMessage()); } catch (CustomerNotInAccountException ex) { System.err.println ("Caught a CustomerNotInAccountException. " + ex.getMessage()); } catch (CustomerNotFoundException ex) { System.err.println ("Caught a CustomerNotFoundException. " + ex.getMessage()); } catch (CustomerInAccountException ex) { System.err.println ("Caught a CustomerInAccountException. " + ex.getMessage()); } catch (IllegalAccountTypeException ex) { System.err.println ("Caught a IllegalAccountTypeException. " + ex.getMessage()); } // catch } // runTests private void printArray(ArrayList list) { Iterator i = list.iterator(); while (i.hasNext()) { AccountDetails details = (AccountDetails)i.next(); System.out.println(); DisplayDetails.print(details); } } // printArray} // class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -