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.

34 lines
1.4 KiB

package java01;
public class BankAccountTest {
public static void main(String[] args) {
System.out.println("========== 1. 测试账户创建 ==========");
BankAccount account = new BankAccount("622202123456789", "张三");
System.out.println("账号:" + account.getAccountNumber());
System.out.println("户主:" + account.getOwnerName());
System.out.println("初始余额:" + account.getBalance());
System.out.println();
System.out.println("========== 2. 测试修改户主姓名 ==========");
account.setOwnerName("张三丰");
System.out.println("修改后户主:" + account.getOwnerName());
System.out.println();
System.out.println("========== 3. 测试存款操作 ==========");
account.deposit(1000);
account.deposit(0);
account.deposit(-500);
System.out.println();
System.out.println("========== 4. 测试取款操作 ==========");
account.withdraw(300);
account.withdraw(800);
account.withdraw(0);
account.withdraw(-200);
System.out.println();
System.out.println("========== 5. 最终状态验证 ==========");
System.out.println("最终户主:" + account.getOwnerName());
System.out.println("最终余额:" + account.getBalance());
}
}