¿Qué clase está causando "indefinido para el tipo de" error?

Sí:

Eclipse está diciendo a mí "indefinido para el tipo de Chore" para getName () en la última línea. Yo no soy la comprensión de dónde está el problema. También tengo una clase de tarea, por lo que está tratando de separar a Nombre de la clase Chore? ¿O hay algo mal en mi clase de gente? (Añadido la clase Chore también)

        System.out.printf("%s's Chores: %n", person.getName());
        for(int i=0; i<person.getNumChores(); i++) {
        System.out.println(person.getChores()[i].getName()); //error here
        }

La gente de clase:

public class People {
    private Chore chores[] = new Chore[48];
    private int numChores = 0;

    private final String name;
    private final int birthYear;
    private int age;

    public void addChore(Chore chore) {
        if(numChores == 48) {
            System.out.println("All chores have been assigned.");
        }
        else {
            chores[numChores++] = chore;    
        }
    }

    public People(String name, int birthYear, int age) {
        this.name = name;
        this.birthYear = birthYear;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public int getBirthYear() {
        return birthYear;
    }

    public int setAge(int birthYear) {
        int age = 2020 - birthYear;
            return age;
        }

    public int getAge(){
        return age;
    }

    public int getNumChores() {
        return numChores;
    }

    public Chore[] getChores() {
        return chores;
    }  
}

Aquí está la clase Chore:

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;
    }
}
Arvind Kumar Avinash:

Usted no tiene getName()método en el interior Chore.

Reemplazar

System.out.println(person.getChores()[i].getName());

con

System.out.println(person.getChores()[i].getChoreName());

Supongo que te gusta

Origin http://10.200.1.11:23101/article/api/json?id=378892&siteId=1
Recomendado
Clasificación