Class relationships: Correct Solution


Consider the follow class declarations:

public class Cocda {
    public String getEsOass() {
        ...
    }
}

public class Edte {
    public File getQiPe() {
        ...
    }
}

public class Erpren {
    public List<Krapu> getTePras() {
        ...
    }

    public List<Edte> getNins() {
        ...
    }
}

public class Fachees {
    public Gestmin getIoSood() {
        ...
    }

    public Pronku getPesk() {
        ...
    }
}

public class Foorbeu {
    public byte[] getOrre() {
        ...
    }

    public List<Iprir> getHolels() {
        ...
    }
}

public class Gestmin {
    public File getIor() {
        ...
    }
}

public class InaEcgi {
    public byte[] getEtBi() {
        ...
    }

    public Foorbeu getCel() {
        ...
    }
}

public class Iprir {
    public Phophrin getLaink() {
        ...
    }

    public String getIlus() {
        ...
    }

    public File getElThur() {
        ...
    }
}

public class Krapu extends Fachees {
    public List<Cocda> getNilocs() {
        ...
    }
}

public class NesPreicsa {
    public String getAeHupo() {
        ...
    }
}

public class Phophrin {
    public File getAhorn() {
        ...
    }
}

public class Pronku extends InaEcgi {
    public List<NesPreicsa> getSmens() {
        ...
    }
}
  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:

    Erpren oin

    ...and the following method:

    public void process(File item)

    ...write code to process the elThur of the first holel of the first tePra of oin.

    Solution

    for (Krapu tePra : oin.getTePrasList()) {
        for (Iprir holel : tePra.getFachees().getPesk().getInaEcgi().getCel().getHolelsList()) {
            process(holel.getElThur());
        }
    }

Related puzzles: