我想实现下面的代码,但是我在类HistoryStudent extends Student,sGrade中出现错误。我如何着手通过超级添加学生成绩? 这是一项任务,我们不应该改变抽象类或下面代码的任何部分。在Java中通过超级访问方法和变量
abstract class Student
{
private String studentID = "" ;
private int studentGrade = 0 ;
public Student (String sID, int sGrade)
{
studentID = sID ;
studentGrade = sGrade ;
return ;
}
public String getStudentID () { return studentID ;}
public double getStudentGrade () { return studentGrade ;}
boolean updateGrade (int grade)
{
boolean check = false ;
studentGrade += grade;
return check ;
}
}
class HistoryStudent extends Student
{
public HistoryStudent (String sID, int sGrade)
{
super(sID,sGrade) ;
return ;
}
boolean updateGrade (int grade)
{
boolean checking = false ;
//Problem here
**sGrade** += grade;
return checking ;
}
}
任何帮助表示赞赏。
ü面对的类 – Kick