Java 哪一类是导致;类型“未定义”;错误?
Eclipse在最后一行告诉我getName()的“未定义类型Chore”。我不明白问题出在哪里。我也有一个杂务类,所以它是否试图从杂务类中提取名称?还是我的人民课出了什么问题?(还添加了Chore类) 下面是杂务类:Java 哪一类是导致;类型“未定义”;错误?,java,methods,Java,Methods,Eclipse在最后一行告诉我getName()的“未定义类型Chore”。我不明白问题出在哪里。我也有一个杂务类,所以它是否试图从杂务类中提取名称?还是我的人民课出了什么问题?(还添加了Chore类) 下面是杂务类: public class Chore{ private final String choreName; private final String difficulty; private final String timesPerWeek; pr
public class Chore{
private final String choreName;
private final String difficulty;
private final String timesPerWeek;
private String location;
private String assigned;
public Chore(String location, String choreName, String timesPerWeek, String difficulty){
this.location = location;
this.choreName = choreName;
this.timesPerWeek = timesPerWeek;
this.difficulty = difficulty;
this.assigned = "N";
}
public Chore(String choreName, String timesPerWeek, String difficulty){
this(choreName, timesPerWeek, difficulty, "Whole house");
this.assigned = "N";
}
public String getChoreName(){
return choreName;
}
public String getDifficulty(){
return difficulty;
}
public String getTimesPerWeek(){
return timesPerWeek;
}
public String getLocation(){
return location;
}
public String setAssigned(){
String assigned = "Y";
return assigned;
}
public String getAssigned(){
return assigned;
}
}
在
Chore
中没有getName()
方法
替换
System.out.println(person.getChores()[i].getName());
与
给我们看看家务活class@DavidZimmerman我添加了它。getName方法在Chore类中的位置是的,这正是我的意思。我觉得自己很笨。Lol而不是(int i=0;i谢谢你。我不知道为什么我没有看到这一点。
public class Chore{
private final String choreName;
private final String difficulty;
private final String timesPerWeek;
private String location;
private String assigned;
public Chore(String location, String choreName, String timesPerWeek, String difficulty){
this.location = location;
this.choreName = choreName;
this.timesPerWeek = timesPerWeek;
this.difficulty = difficulty;
this.assigned = "N";
}
public Chore(String choreName, String timesPerWeek, String difficulty){
this(choreName, timesPerWeek, difficulty, "Whole house");
this.assigned = "N";
}
public String getChoreName(){
return choreName;
}
public String getDifficulty(){
return difficulty;
}
public String getTimesPerWeek(){
return timesPerWeek;
}
public String getLocation(){
return location;
}
public String setAssigned(){
String assigned = "Y";
return assigned;
}
public String getAssigned(){
return assigned;
}
}
System.out.println(person.getChores()[i].getName());
System.out.println(person.getChores()[i].getChoreName());