Академический Документы
Профессиональный Документы
Культура Документы
Bank.addCustomer("Diego", "Diaz"); customer = Bank.getCustomer(0); customer.addAccount(new SavingsAccount(500.00, 0.05)); customer.addAccount(new CheckingAccount(200.00, 500.00));
customer = Bank.getCustomer(0); account = customer.getAccount(1); System.out.println("Cliente [" + customer.getLastName() + ", " + customer.getFirstName() + "]" DIAZ GARCIA DIEGO DANIEL ISC
Programacin Orientada a Objetos + " has a checking balance of " + account.getBalance() + " with a 500.00 overdraft protection."); try { System.out.println("Checking Acct [Diego Diaz] : deposito 1400.00"); account.deposit(1400.00); System.out.println("Checking Acct [Diego Diaz] : Retiro 200.00"); account.withdraw(200.00); System.out.println("Checking Acct [Diego Diaz] : deposito 1700.50"); account.deposit(1700.50); System.out.println("Checking Acct [Diego Diaz] : Retiro 125.62"); account.withdraw(125.62); System.out.println("Checking Acct [Diego Diaz] : Retiro 600.00"); account.withdraw(600.00); } catch (OverdraftException e1) { System.out.println("Exception: " + e1.getMessage() + " Deficit: " + e1.getDeficit()); } finally { System.out.println("Cliente [" + customer.getLastName() + ", " + customer.getFirstName() + "]" + " has a checking balance of " + account.getBalance()); } System.out.println();
Programacin Orientada a Objetos account = customer.getAccount(0); System.out.println("Cliente [" + customer.getLastName() + ", " + customer.getFirstName() + "]" + " has a savings balance of " + account.getBalance()); try { System.out.println("Savings Acct [Estefani Diaz] : Retiro 450.00"); account.withdraw(450.00); System.out.println("Savings Acct [Estefani Diaz] : deposito 79.00"); account.deposit(79.00); System.out.println("Savings Acct [Estefani Diaz] : Retiro 2000.00"); account.withdraw(2000.00); } catch (OverdraftException e1) { System.out.println("Exception: " + e1.getMessage() + " Deficit: " + e1.getDeficit()); } finally { System.out.println("Cliente [" + customer.getLastName() + ", " + customer.getFirstName() + "]" + " has a savings balance of " + account.getBalance()); } System.out.println();
customer = Bank.getCustomer(2); account = customer.getAccount(0); System.out.println("Cliente [" + customer.getLastName() DIAZ GARCIA DIEGO DANIEL ISC
Programacin Orientada a Objetos + ", " + customer.getFirstName() + "]" + " has a savings balance of " + account.getBalance()); try { System.out.println("Savings Acct [Leticia Garcia] : Retiro 100.00"); account.withdraw(100.00); System.out.println("Savings Acct [Leticia Garcia] : deposito 255.00"); account.deposit(255.00); System.out.println("Savings Acct [Leticia Garcia] : Retiro 1650.00"); account.withdraw(1650.00); } catch (OverdraftException e1) { System.out.println("Exception: " + e1.getMessage() + " Deficit: " + e1.getDeficit()); } finally { System.out.println("Customer [" + customer.getLastName() + ", " + customer.getFirstName() + "]" + " has a savings balance of " + account.getBalance()); } System.out.println();
customer = Bank.getCustomer(3); account = customer.getAccount(0); System.out.println("Cliente [" + customer.getLastName() + ", " + customer.getFirstName() + "]" + " has a savings balance of " DIAZ GARCIA DIEGO DANIEL ISC
Programacin Orientada a Objetos + account.getBalance()); try { System.out.println("Savings Acct [Felipe Diaz] : deposito 15000.00"); account.deposit(15000.00); System.out.println("Savings Acct [Felipe Diaz] : deposito 500.00"); account.deposit(500.00); System.out.println("Savings Acct [Felipe Diaz] : Retiro 1000.00"); account.withdraw(1000.00); System.out.println("Savings Acct [Felipe Diaz] : deposito 420.00"); account.deposit(420.00); System.out.println("Savings Acct [Felipe Diaz] : Retiro 6000.00"); account.withdraw(6000.00); System.out.println("Savings Acct [Felipe Diaz] : Retiro 8000.00"); account.withdraw(8000.00); } catch (OverdraftException e1) { System.out.println("Exception: " + e1.getMessage() + " Deficit: " + e1.getDeficit()); } finally { System.out.println("Cliente [" + customer.getLastName() + ", " + customer.getFirstName() + "]" + " has a savings balance of " + account.getBalance()); } } }
ISC
public class Bank { private static Customer[] customers = new Customer[10]; private static int numberOfCustomers = 0;
public static void addCustomer(String f, String l) { int i = numberOfCustomers++; customers[i] = new Customer(f,l); }
public static Customer getCustomer(int customer_index) { return customers[customer_index]; } } DIAZ GARCIA DIEGO DANIEL ISC
public class OverdraftException extends Exception { private final double deficit; public OverdraftException(String msg, double deficit) { super(msg); this.deficit = deficit; }
ISC
Programacin Orientada a Objetos public class Customer { private String firstName; private String lastName; private Account[] accounts; private int numberOfAccounts;
ISC
ISC
public void withdraw(double amt) throws OverdraftException { if ( amt <= balance ) { balance = balance - amt; } else { throw new OverdraftException("Insufficient funds", amt - balance); } } }
ISC
public CheckingAccount(double initBalance, double overdraftAmount) { super(initBalance); this.overdraftAmount = overdraftAmount; } public CheckingAccount(double initBalance) { this(initBalance, 0.0); }
} else {
} else {
// Yes, there is enough balance to cover the amount // Proceed as usual balance = balance - amount; } } }
ISC
Programacin Orientada a Objetos public class SavingsAccount extends Account { private double interestRate;
ISC