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.
26 lines
986 B
26 lines
986 B
public class BankAccountDemo {
|
|
public static void main(String[] args) {
|
|
System.out.println("====== 开始运行测试程序 ======\n");
|
|
|
|
BankAccount myAccount = new BankAccount("CN-888", "王五");
|
|
myAccount.deposit(5000.0);
|
|
myAccount.deposit(2000.0);
|
|
|
|
System.out.println("当前户主: " + myAccount.getOwnerName());
|
|
System.out.println("当前余额: $" + myAccount.getBalance());
|
|
|
|
myAccount.withdraw(1000.0);
|
|
myAccount.withdraw(100000.0);
|
|
myAccount.withdraw(-500.0);
|
|
|
|
System.out.println("最终余额: $" + myAccount.getBalance());
|
|
|
|
BankAccount friendAccount = new BankAccount("CN-999", "赵六");
|
|
friendAccount.deposit(100.0);
|
|
|
|
System.out.println("王五的余额: $" + myAccount.getBalance());
|
|
System.out.println("赵六的余额: $" + friendAccount.getBalance());
|
|
|
|
System.out.println("\n====== 测试程序结束 ======");
|
|
}
|
|
}
|
|
|