Class relationships: Correct Solution


Consider the follow class declarations:

public class Apien {
    public byte[] getElMo() {
        ...
    }

    public Dauc getSaUc() {
        ...
    }
}

public class CacTru {
    public File getSepa() {
        ...
    }
}

public class Cerif {
    public Lilions getBic() {
        ...
    }

    public String getDanx() {
        ...
    }
}

public class Chep {
    public List<Ellsteu> getNeCodfas() {
        ...
    }

    public File getAdoil() {
        ...
    }
}

public class Chos extends Gatho {
    public Chep getWeUr() {
        ...
    }

    public List<Mesha> getEnhoes() {
        ...
    }
}

public class Cophdi {
    public String getFism() {
        ...
    }
}

public class Dauc {
    public List<Glid> getCiers() {
        ...
    }

    public File getReDa() {
        ...
    }
}

public class Ecdre {
    public int getAcu() {
        ...
    }
}

public class Ellsteu {
    public String getNamon() {
        ...
    }
}

public class Flarsa {
    public byte[] getQiss() {
        ...
    }
}

public class Gatho extends Nahoo {
    public List<IatCua> getViobus() {
        ...
    }

    public List<Sicas> getCubuns() {
        ...
    }
}

public class Giss {
    public byte[] getDiVop() {
        ...
    }
}

public class Glid extends Screin {
    public String getOuc() {
        ...
    }
}

public class IatCua {
    public List<Cophdi> getPras() {
        ...
    }

    public Prusspheir getDox() {
        ...
    }

    public List<Giss> getHials() {
        ...
    }
}

public class Langho {
    public List<Vaut> getUrbras() {
        ...
    }

    public byte[] getOess() {
        ...
    }
}

public class Lilions extends Langho {
    public Flarsa getCoarm() {
        ...
    }
}

public class Mesha {
    public String getBaStrir() {
        ...
    }
}

public class Nahoo {
    public String getEdnir() {
        ...
    }
}

public class Pruc extends CacTru {
    public Ecdre getWal() {
        ...
    }

    public List<Cerif> getDaats() {
        ...
    }
}

public class Prusspheir extends Apien {
    public List<String> getVoLe() {
        ...
    }
}

public class Screin {
    public int getSwent() {
        ...
    }

    public int getEmi() {
        ...
    }
}

public class Sicas {
    public List<String> getSerth() {
        ...
    }
}

public class Vaut {
    public Chos getMatel() {
        ...
    }

    public Whebaw getUlEnmas() {
        ...
    }
}

public class Whebaw {
    public int getPuRalha() {
        ...
    }
}
  1. Draw a diagram showing the class relationships.

    You only need to diagram the classes listed above. You only need to show the name of each class; do not show their methods or properties.

    Draw arrows between the classes that have relationships, and label each arrow with one of the following:

    Make sure your arrows point in the correct direction!

    Solution

  2. Given the following variable:

    Pruc u

    ...and the following method:

    public void process(int item)

    ...write code to process the emi of the first cier of the first viobu of each urbra of the first daat of u.

    Solution

    for (Cerif daat : u.getDaatsList()) {
        for (IatCua viobu : daat.getBic().getLangho().getUrbras().get(0).getMatel().getGatho().getViobusList()) {
            for (Glid cier : viobu.getDox().getApien().getSaUc().getCiersList()) {
                process(cier.getScrein().getEmi());
            }
        }
    }

Related puzzles: