A
错误
应该加mc1.setValue(10);
mc2.setValue(10);
System.out.println(mc1.getValue());
System.out.println(mc2.getValue());
package orj.jsoft.homework;
// Account 类
public class Account {
private long id; // 账户
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getPassword() {
return null;
}
public void setPassword(String password) {
if(password.length()==6){
this.password = password;
}else{
System.out.println("请修改您的密码");
}
}
private double balance; //余额
private String password; //密码
}
// SavingAccount类
package orj.jsoft.homework;
public class SavingAccount extends Account{
private double interestRate; //存款利率
public double getInterestRate() {
return interestRate;
}
public void setInterestRate(double interestRate) {
if(interestRate>0&&interestRate<0.1){
this.interestRate = interestRate;
}else{
System.out.println("利率不对");
}
}
}
//CreditAccount类
package orj.jsoft.homework;
public class CreditAccount extends Account{
private double creditLine; //信用额度
public double getCreditLine() {
return creditLine;
}
public void setCreditLine(double creditLine) {
this.creditLine = creditLine;
}
}