gpt4 book ai didi

java - 找不到 super 语句的符号

转载 作者:行者123 更新时间:2023-12-02 06:46:42 25 4
gpt4 key购买 nike

这是一段带有继承和多态方法的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);}
}

全日制学生类

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语句的符号类。

super(i,nm,code,pt); 

最佳答案

由于错误试图告诉您,您的父类(super class)没有任何采用参数的构造函数。

关于java - 找不到 super 语句的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18559002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com