[질문] 이렇게 질문해도 되는지 모르겠네요
해사랑해
혼자 하다 1시간 정도 고민하다 답이 안 나와서질문합니다. 상속에대한 공부 부분에서 푸는건데 에러가 나서요
자세히 보실 필요없이... 아래 에러부 첨부해 놨는데 보시면 아실거 같내요..
그럼 부탁드리겠습니다.class CollegeStudent
{
String Name;
int Number;
String Department;
int Grade;
int EarnedCredits;
public CollegeStudent(String Name, int Number, String Department, int Grade, int EarnedCredits )
{
setName(Name);
setNumber(Number);
setDepartment(Department);
setGrade(Grade);
setEarnedCredits(EarnedCredits);
}
public String getName()
{
return Name;
}
public int getNumber()
{
return Number;
}
public String getDepartment()
{
return Department;
}
public int getGrade()
{
return Grade;
}
public int getEarnedCredits()
{
return EarnedCredits;
}
public void setName(String Name)
{
this.Name = Name;
}
public void setNumber(int Number)
{
this.Number = Number;
}
public void setDepartment(String Department)
{
this.Department = Department;
}
public void setGrade(int Grade)
{
this.Grade = Grade;
}
public void setEarnedCredits(int EarnedCredits)
{
this.EarnedCredits = EarnedCredits;
}
public String toString()
{
return(학생이름 : + this.Name + \n + 학번 : + this.Number + \n + this.Department + \n+ 학년 : + this.Grade + \n + 이수학점 : + this.EarnedCredits + /n);
}
}
class UnderStudent extends CollegeStudent
{
int EarnedCredits;
String ClubName;
public UnderStudent(String Name, int Number, String Department, int Grade, int EarnedCredits, String ClubName)
{
super.Name = Name;
super.Number = Number;
super.Department = Department;
super.Grade = Grade;
super.EarnedCredits = EarnedCredits;
}
public String getClubName()
{
return(ClubName);
}
public void setClubName(String ClubName)
{
this.ClubName = ClubName;
}
public String toString()
{
return(super.toString + 동아리 이름 : + this.ClubName + \n);
}
}
class GraduateStudent extends CollegeStudent
{
String AssistentType;
double PayRate;
public GraduateStudent(String Name, int Number, String Department, int Grade, int EarnedCredits, String AssistentType, double PayRate)
{
super.Name = Name;
super.Number = Number;
super.Department = Department;
super.Grade = Grade;
super.EarnedCredits = EarnedCredits;
}
public String getAssistentType()
{
return(AssistentType);
}
public double getPayRate()
{
return(PayRate);
}
public void setAssistentType(String AssistentType)
{
this.AssistentType = AssistentType;
}
public void setPayRate(double PayRate)
{
this.PayRate = PayRate;
}
public String toString()
{
return(super.toString + 조교유형 : + this.AssistentType + \n + 장학금 비율 : + this.PayRate + \n);
}
}
class Driver
{
public static void main(String[] argv)
{
CollegeStudent student1 = new CollegeStudent(세리, 9024729, 체육, 4, 135);
UnderStudent student2 = new UnderStudent(지은, 9320985, 체육, 1, 18, 골프);
GraduateStudent student3 = new GraduateStudent(경주, 8014832, 체육, 2, 24, 강의 조교, 1.0d);
System.out.println(student1.toString());
System.out.println(student2.toString());
System.out.println(student3.toString());
}
}
여기부터 에러부...
CollegeStudent.java:66: cannot find symbol
symbol : constructor CollegeStudent()
location: class CollegeStudent
{
^
CollegeStudent.java:83: cannot find symbol
symbol : variable toString
location: class CollegeStudent
return(super.toString + 동아리 이름 : + this.ClubName + \n);
&nbsbsp; ^
CollegeStudent.java:91: cannot find symbol
symbol : constructor CollegeStudent()
location: class CollegeStudent
{
^
CollegeStudent.java:116: cannot find symbol
symbol : variable toString
location: class CollegeStudent
return(super.toString + 조교유형 : + this.AssistentType + \n + 장학
금 비율 : + this.PayRate + \n);
^
4 errors에디가 에러인지 모르겠네요...
-
개힘
대충 훌터보니 2가지 에러이군요....
하나는 toString 에러....이건 toString는 메소드 입니다. 변수가 아니지요...즉 toString() 이렇게 불러서 사용해야 합니다.
다른 하나는 CollegeStudent() 생성자 메소드 오류이군요 생성자 메소드를 찾을수가 없다고 하네요...
무언가 오류가 났거나 매개변수가 다르지 않는지 확인해 보세요 -
안녕나야
와우 길다 -_-;