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.
29 lines
991 B
29 lines
991 B
public class TestBankAccount {
|
|
public static void main(String[] args) {
|
|
// 创建银行账户
|
|
BankAccount account = new BankAccount("123456789", "张三");
|
|
|
|
// 显示初始账户信息
|
|
System.out.println("初始账户信息:");
|
|
account.displayInfo();
|
|
|
|
// 测试存款
|
|
System.out.println("测试存款:");
|
|
account.deposit(1000);
|
|
account.deposit(-500); // 测试非法存款金额
|
|
|
|
// 测试取款
|
|
System.out.println("测试取款:");
|
|
account.withdraw(500);
|
|
account.withdraw(1000); // 测试余额不足
|
|
account.withdraw(-200); // 测试非法取款金额
|
|
|
|
// 测试修改户主姓名
|
|
System.out.println("测试修改户主姓名:");
|
|
account.setOwnerName("李四");
|
|
account.displayInfo();
|
|
|
|
// 测试查询余额
|
|
System.out.println("当前余额:" + account.getBalance());
|
|
}
|
|
}
|