Class relationships: Correct Solution


Consider the follow class declarations:

public class Chege extends Dinsio {
    public int getCaPi() {
        ...
    }

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

public class Cingde {
    public Chege getNic() {
        ...
    }

    public String getCioc() {
        ...
    }
}

public class Denple {
    public byte[] getShiop() {
        ...
    }
}

public class Dinsio {
    public String getWol() {
        ...
    }
}

public class Dongplas extends Denple {
    public List<Phruear> getRerps() {
        ...
    }
}

public class Duss {
    public File getSilmo() {
        ...
    }
}

public class Foest extends Cingde {
    public Peus getUphe() {
        ...
    }

    public List<Ingo> getMiAfs() {
        ...
    }
}

public class Ingo {
    public String getEeFroc() {
        ...
    }
}

public class KroTupis extends Dongplas {
    public String getOego() {
        ...
    }
}

public class Odgorn {
    public Paund getOsCeng() {
        ...
    }

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

public class Paund {
    public List<KroTupis> getElItats() {
        ...
    }

    public Twoia getEjesm() {
        ...
    }
}

public class Peus {
    public File getLeTes() {
        ...
    }
}

public class Phruear {
    public List<Duss> getBiPrades() {
        ...
    }

    public Foest getWic() {
        ...
    }
}

public class Twoia {
    public List<String> getShept() {
        ...
    }
}
  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:

    Odgorn si

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the pha of the first rerp of the first elItat of si.

    Solution

    for (KroTupis elItat : si.getOsCeng().getElItatsList()) {
        for (Phruear rerp : elItat.getDongplas().getRerpsList()) {
            process(rerp.getWic().getCingde().getNic().getPha());
        }
    }

Related puzzles: