Class relationships: Correct Solution


Consider the follow class declarations:

public class Classpol extends Engzert {
    public List<Essgart> getUnSirms() {
        ...
    }
}

public class Emproa {
    public Jiphal getEnWerg() {
        ...
    }

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

public class Engzert {
    public String getCiea() {
        ...
    }
}

public class Essgart {
    public Trep getShir() {
        ...
    }

    public int getLol() {
        ...
    }

    public File getFiam() {
        ...
    }
}

public class Gepdi extends Pels {
    public byte[] getMiai() {
        ...
    }
}

public class Grenthoss extends Tidwol {
    public List<Slanbria> getNuResms() {
        ...
    }

    public List<Emproa> getOiAas() {
        ...
    }
}

public class Ilooph {
    public String getLatis() {
        ...
    }
}

public class Jiphal {
    public List<Gepdi> getIltres() {
        ...
    }

    public int getUmGri() {
        ...
    }
}

public class Pels {
    public Sqiha getAlPraec() {
        ...
    }

    public Classpol getAmust() {
        ...
    }
}

public class Phore {
    public List<String> getAng() {
        ...
    }
}

public class Preck extends Sarprent {
    public List<Ilooph> getSiOms() {
        ...
    }
}

public class Sarprent extends Phore {
    public Grenthoss getJoGa() {
        ...
    }
}

public class Slanbria {
    public List<String> getPou() {
        ...
    }
}

public class Sqiha {
    public byte[] getEnnel() {
        ...
    }
}

public class Tidwol {
    public String getDoid() {
        ...
    }
}

public class Trep {
    public String getUiSeack() {
        ...
    }
}
  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:

    Preck aspi

    ...and the following method:

    public void process(File item)

    ...write code to process the fiam of the first unSirm of the first iltre of each oiAa of aspi.

    Solution

    for (Gepdi iltre : aspi.getSarprent().getJoGa().getOiAas().get(0).getEnWerg().getIltresList()) {
        for (Essgart unSirm : iltre.getPels().getAmust().getUnSirmsList()) {
            process(unSirm.getFiam());
        }
    }

Related puzzles: