java account_【Java基础 项目实例--Bank项目5】Account 和 customer 对象等 继承、多态、方法的重写...

packageTestBanks;import Banking_5.*;public classTestBanking_5 {public static voidmain(String[] args) {

Bank bank= newBank();

Customer customer;

Account account;//

//Create Bank customers and their account

System.out.println("Creating the customer Jane Smith.");

System.out.println("Creating her Savings Account with a 500.00 balance and 3% interest.");

bank.addCustomer("Jane", "Simms");

customer= bank.getCustomer(0);

account= new SavingAccount(500,0.03);

customer.setAccount(account);

System.out.println("Creating the customer Owen Bryant.");//code

bank.addCustomer("Owen","Bryant");

customer=bank.getCustomer(1);

account=new CheckingAccount(500,0);

customer.setAccount(account);

System.out.println("Creating his Checking Account with a 500.00 balance and no overdraft protection.");//code

System.out.println("Creating the customer Tim Soley.");

bank.addCustomer("Tim", "Soley");

customer= bank.getCustomer(2);

account=new CheckingAccount(500,500);

customer.setAccount(account);

System.out.println("Creating his Checking Account with a 500.00 balance and 500.00 in overdraft protection.");//code

System.out.println("Creating the customer Maria Soley.");

bank.addCustomer("Maria", "Soley");

customer= bank.getCustomer(3);

System.out.println("Maria shares her Checking Account with her husband Tim.");

customer.setAccount(bank.getCustomer(2).getAccount());

System.out.println();//

//Demonstrate behavior of various account types//

//Test a standard Savings Account

System.out.println("Retrieving the customer Jane Smith with her savings account.");

customer= bank.getCustomer(0);

account=customer.getAccount();//Perform some account transactions

System.out.println("Withdraw 150.00: " + account.withdraw(150.00));

System.out.println("Deposit 22.50: " + account.deposit(22.50));

System.out.println("Withdraw 47.62: " + account.withdraw(47.62));

System.out.println("Withdraw 400.00: " + account.withdraw(400.00));//Print out the final account balance

System.out.println("Customer [" +customer.getLastName()+ ", " +customer.getFirstName()+ "] has a balance of " +account.getBalance());

System.out.println();//Test a Checking Account w/o overdraft protection

System.out.println("Retrieving the customer Owen Bryant with his checking account with no overdraft protection.");

customer= bank.getCustomer(1);

account=customer.getAccount();//Perform some account transactions

System.out.println("Withdraw 150.00: " + account.withdraw(150.00));

System.out.println("Deposit 22.50: " + account.deposit(22.50));

System.out.println("Withdraw 47.62: " + account.withdraw(47.62));

System.out.println("Withdraw 400.00: " + account.withdraw(400.00));//Print out the final account balance

System.out.println("Customer [" +customer.getLastName()+ ", " +customer.getFirstName()+ "] has a balance of " +account.getBalance());

System.out.println();//Test a Checking Account with overdraft protection

System.out.println("Retrieving the customer Tim Soley with his checking account that has overdraft protection.");

customer= bank.getCustomer(2);

account=customer.getAccount();//Perform some account transactions

System.out.println("Withdraw 150.00: " + account.withdraw(150.00));

System.out.println("Deposit 22.50: " + account.deposit(22.50));

System.out.println("Withdraw 47.62: " + account.withdraw(47.62));

System.out.println("Withdraw 400.00: " + account.withdraw(400.00));//Print out the final account balance

System.out.println("Customer [" +customer.getLastName()+ ", " +customer.getFirstName()+ "] has a balance of " +account.getBalance());

System.out.println();//Test a Checking Account with overdraft protection

System.out.println("Retrieving the customer Maria Soley with her joint checking account with husband Tim.");

customer= bank.getCustomer(3);

account=customer.getAccount();//Perform some account transactions

System.out.println("Deposit 150.00: " + account.deposit(150.00));

System.out.println("Withdraw 750.00: " + account.withdraw(750.00));//Print out the final account balance

System.out.println("Customer [" +customer.getLastName()+ ", " +customer.getFirstName()+ "] has a balance of " +account.getBalance());

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值