Class relationships: Correct Solution


Consider the follow class declarations:

public class Blath {
    public List<String> getIsCe() {
        ...
    }
}

public class Chani {
    public NaoBucfoust getEdOu() {
        ...
    }

    public Plustsa getCaCin() {
        ...
    }
}

public class Ciastcil {
    public File getPle() {
        ...
    }

    public List<Wobas> getNoLoouns() {
        ...
    }
}

public class Essrie {
    public List<String> getOrOnob() {
        ...
    }

    public String getBepso() {
        ...
    }
}

public class Grafu {
    public File getStis() {
        ...
    }
}

public class Medrorm extends Essrie {
    public byte[] getCes() {
        ...
    }
}

public class NaoBucfoust {
    public String getCosad() {
        ...
    }
}

public class Orbeng {
    public String getPiEe() {
        ...
    }
}

public class PelIbooc {
    public List<Grafu> getMiEns() {
        ...
    }

    public int getCiunu() {
        ...
    }
}

public class Plustsa extends Ciastcil {
    public int getSti() {
        ...
    }
}

public class Podcap {
    public List<Saknel> getElJids() {
        ...
    }

    public List<Medrorm> getOmas() {
        ...
    }
}

public class Saknel {
    public int getSprec() {
        ...
    }
}

public class Sphe {
    public List<String> getIhe() {
        ...
    }
}

public class Steut extends Utie {
    public Blath getTaKa() {
        ...
    }
}

public class Utie {
    public Orbeng getOng() {
        ...
    }

    public PelIbooc getEop() {
        ...
    }

    public List<Chani> getAnDas() {
        ...
    }
}

public class Wobas extends Sphe {
    public Podcap getOstpa() {
        ...
    }
}
  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:

    Steut e

    ...and the following method:

    public void process(String item)

    ...write code to process the bepso of the first oma of each noLooun of the first anDa of e.

    Solution

    for (Chani anDa : e.getUtie().getAnDasList()) {
        for (Medrorm oma : anDa.getCaCin().getCiastcil().getNoLoouns().get(0).getOstpa().getOmasList()) {
            process(oma.getEssrie().getBepso());
        }
    }

Related puzzles: