package banking; public class Account { private double balance; public Account(double balance) { this.balance=balance; } public double getBalance() { System.out.println("当前余额为:"+balance+"元"); return balance; } public double deposit(double add){ balance+=add; System.out.println("存钱"+add+"元,当余额为"+balance+"元"); return balance; } boolean withdraw(double get){ if(get<=balance) { System.out.println("取钱"+get+"元,当余额为"+balance+"元"); return true; } else { System.out.println("‘余额不足"); return false; } } }
时间: 2024-11-03 05:31:36