这是具有继承和多态方法的Java代码。
学生班
public abstract class Student
{
protected long id;
protected String name;
protected String programCode;
protected int part;
public Student(){
id=0;
name=" ";
programCode=" ";
part=0;
}
public void setStudent(long i,String nm,String code,int pt){
id=i;
name=nm;
programCode=code;
part=pt;
}
public long getId() {return id;}
public String getName() {return name;}
public String getProgramCode() {return programCode;}
public int getPart() {return part;}
public abstract double calculateFees();
public String toString(){
return ("ID: "+id+"\nName: "+name+"\nProgram Code: "+programCode+"\nPart: "+part);}
}
FullTimeStudent类
public class FullTimeStudent extends Student{
protected String collegeName;
protected String roomNumber;
public FullTimeStudent(){
super();
collegeName=" ";
roomNumber=" ";
}
public FullTimeStudent(long i,String nm,String code,int pt,
String collegeNm,String roomNum){
super(i,nm,code,pt); //can't find symbol here
collegeName=collegeNm;
roomNumber=roomNum;
}
public void setFullTimeStudent(String collegeNm,String roomNum){
collegeName=collegeNm;
roomNumber=roomNum;
}
public String getCollegeName() {return collegeName;}
public String getRoomNumber() {return roomNumber;}
public double calculateFees(){
double fee=0, collegefee=0, totalfee=0;
if(programCode.equals("BIT")){
fee=2000;
}
else if(programCode.equals("BCHE")){
fee=2300;
}
else if(programCode.equals("BPHY")){
fee=3200;
}
else if(programCode.equals("BBIO"))
fee=2700;
}
if(collegeName.equals("Jati")){
collegefee=200;
}
else if(collegeName.equals("Cengal")){
collegefee=350;
}
else if(collegeName.equals("Dahlis")){
collegefee=420;
totalfee=fee+collegefee;
return totalfee;
}
public String toString(){
return super.toString()+"\nCollege Name: "+collegeName+"\nRoom Number"+roomNumber;
}
}
似乎在FullTimeStudent中找不到超级语句的符号
类。
super(i,nm,code,pt);
最佳答案
由于错误试图告诉您,您的超类没有任何带参数的构造函数。