Class relationships: Correct Solution


Consider the follow class declarations:

public class Cuarnong extends Epir {
    public Onsosm getPeCliss() {
        ...
    }
}

public class Epir {
    public String getAcen() {
        ...
    }
}

public class Eroc {
    public List<String> getIash() {
        ...
    }
}

public class Meltmi {
    public List<Eroc> getCatas() {
        ...
    }

    public Phesni getGlo() {
        ...
    }
}

public class Onsosm extends Roshdac {
    public String getEgran() {
        ...
    }

    public List<String> getPsoru() {
        ...
    }
}

public class Phesni {
    public List<Plimec> getErCheams() {
        ...
    }

    public int getOsTruea() {
        ...
    }
}

public class Plimec extends Tuss {
    public String getEptac() {
        ...
    }
}

public class Roshdac {
    public Slarsno getPaJepi() {
        ...
    }

    public String getIsCagh() {
        ...
    }
}

public class Slarsno {
    public List<String> getChroc() {
        ...
    }
}

public class Tuss {
    public File getPran() {
        ...
    }

    public List<Cuarnong> getLics() {
        ...
    }
}
  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:

    Meltmi on

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the psoru of the first lic of each erCheam of on.

    Solution

    for (Cuarnong lic : on.getGlo().getErCheams().get(0).getTuss().getLicsList()) {
        process(lic.getPeCliss().getPsoru());
    }

Related puzzles: