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.
19 lines
501 B
19 lines
501 B
public class Account {
|
|
private double balance;
|
|
|
|
public Account(double initialBalance) {
|
|
this.balance = initialBalance;
|
|
}
|
|
|
|
public void withdraw(double amount) throws InsufficientFundsException {
|
|
if (amount > balance) {
|
|
throw new InsufficientFundsException(balance);
|
|
}
|
|
balance -= amount;
|
|
System.out.println("取款成功!当前余额:" + balance);
|
|
}
|
|
|
|
public double getBalance() {
|
|
return balance;
|
|
}
|
|
}
|