package test;
import banking5.Account;
import banking5.Bank;
import banking5.CheckingAccount;
import banking5.Customer;
import banking5.SavingAccount;
/*
* This class creates the program to test the banking classes.
* It creates a new Bank, sets the Customer (with an initial balance),
* and performs a series of transactions with the Account object.
*/
public class TestBanking_5 {
public static void main(String[] args) {
Bank bank = new Bank();
Customer customer;
Account account;
//
// Create bank customers and their accounts
//
System.out.println("Creating the customer Jane Smith.");
bank.addCustomer("Jane", "Simms");
// code
System.out
.println("Creating her Savings Account with a 500.00 balance and 3% interest.");
// code
bank.getCustomer(0).setAccount(new SavingAccount(500, 0.03));
System.out.println("Creating the customer Owen Bryant.");
// code
bank.addCustomer("Owen", "Bryant");
customer = bank.getCustomer(1);
System.out
.println("Creating his Checking Account with a 500.00 balance and no overdraft protection.");
// code
customer.setAccount(new CheckingAccount(500));
System.out.println("Creating the customer Tim Soley.");
bank.addCustomer("Tim", "Soley");
customer = bank.getCustomer(2);
System.out
.println("Creating his Checking Account with a 500.00 balance and 500.00 in overdraft protection.");
// code
customer.setAccount(new CheckingAccount(500, 500));
System.out.println("Creating the customer Maria Soley.");
// code
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());
}
}
逃逸的卡路里
- 粉丝: 1w+
- 资源: 5356
最新资源
- springboot145基于java的在线问卷调查系统的设计与实现.zip
- 步进电机位置闭环控制仿真 simulink 电机本体模块化搭建
- springboot147校园失物招领系统.zip
- springboot150基于springboot的贸易行业crm系统.zip
- springboot148江理工文档管理系统的设计与实现.zip
- springboot149智慧图书管理系统设计与实现.zip
- springboot152基于springboot的的学生干部管理系统.zip
- springboot151基于web的人力资源管理系统的设计与实现.zip
- springboot153相亲网站.zip
- springboot154基于Spring Boot智能无人仓库管理.zip
- springboot155基于JAVA语言的在线考试与学习交流网页平台.zip
- springboot156基于SpringBoot+Vue的常规应急物资管理系统.zip
- springboot157基于springboot的线上辅导班系统的开发与设计.zip
- springboot158基于springboot的医院资源管理系统.zip
- springboot159基于springboot框架开发的景区民宿预约系统的设计与实现.zip
- HTML5实现的手机验证抽奖领券效果源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈