You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
896 B
30 lines
896 B
package w3;
|
|
|
|
public class BankAccountTest {
|
|
public static void main(String[] args) {
|
|
// 1. 创建一个银行账户
|
|
BankAccount account = new BankAccount("622202123456789", "客户A");
|
|
|
|
// 2. 打印初始信息
|
|
account.printAccountInfo();
|
|
|
|
// 3. 测试存款
|
|
account.deposit(1000);
|
|
account.printAccountInfo();
|
|
|
|
// 4. 测试取款
|
|
account.withdraw(300);
|
|
account.printAccountInfo();
|
|
|
|
// 5. 测试修改户主姓名
|
|
account.setOwnerName("客户A-新版");
|
|
System.out.println("修改后户主姓名:" + account.getOwnerName());
|
|
|
|
// 6. 测试异常情况(取款金额>余额)
|
|
account.withdraw(800);
|
|
// 测试异常情况(存款金额<=0)
|
|
account.deposit(-500);
|
|
// 测试异常情况(取款金额<=0)
|
|
account.withdraw(-100);
|
|
}
|
|
}
|