根据以下要求完善Account.java,注意在未完成ManageAccounts.java前程序无法运行。n 完善toString方法,返回一个字符串包含name, account number, balance.n 完善chargeFee方法,从账户中扣除10元的服务费n 修改chargeFee方法,原方法返回值类型为void,修改后让它返回新的balancen 完善changeName方法,用string类型作为参数名来修改账户名public class Account{private double balance;private String name;private long acctNum;//----------------------------------------------//Constructor -- initializes balance, owner, and account number//----------------------------------------------public Account(double initBal, String owner, long number){balance = initBal;name = owner;acctNum = number;}//----------------------------------------------// Checks to see if balance is sufficient for withdrawal.// If so, decrements balance by amount; if not, prints message.//----------------------------------------------public void withdraw(double amount){if (balance >= amount)balance -= amount;elseSystem.out.println("Insufficient funds");}//----------------------------------------------// Adds deposit amount to balance.//52 Chapter 4: Writing Classes//----------------------------------------------public void deposit(double amount){balance += amount;}//----------------------------------------------// Returns balance.//----------------------------------------------public double getBalance(){return balance;}//----------------------------------------------// Returns a string containing the name, account number, and balance.//----------------------------------------------public String toString(){ return string}//----------------------------------------------// Deducts $10 service fee//----------------------------------------------public void chargeFee(){}//----------------------------------------------// Changes the name on the account//----------------------------------------------public void changeName(String newName){}}
添加回答
举报
0/150
提交
取消