Class relationships: Correct Solution


Consider the follow class declarations:

public class CesIned {
    public int getGualo() {
        ...
    }
}

public class Ciul {
    public Ispaght getTris() {
        ...
    }

    public int getLec() {
        ...
    }
}

public class Edpung {
    public byte[] getAnAesa() {
        ...
    }
}

public class Hangwid {
    public byte[] getHeol() {
        ...
    }

    public Nuwass getEsIssol() {
        ...
    }
}

public class Hasa extends Ibar {
    public List<Psesh> getLoPses() {
        ...
    }
}

public class Hoodmith extends Wopra {
    public String getHoul() {
        ...
    }
}

public class Ibar {
    public int getDrin() {
        ...
    }

    public IedAsro getLaNi() {
        ...
    }
}

public class IedAsro {
    public Puph getPewa() {
        ...
    }

    public List<Phater> getRoales() {
        ...
    }
}

public class Ispaght {
    public String getQipe() {
        ...
    }

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

public class Nuwass {
    public int getFluir() {
        ...
    }
}

public class Occiss extends Pramof {
    public Hoodmith getCalo() {
        ...
    }
}

public class Panbal {
    public List<Umic> getEbges() {
        ...
    }

    public List<Sengtioc> getSkebes() {
        ...
    }
}

public class Phater {
    public Panbal getOblo() {
        ...
    }

    public String getOrFos() {
        ...
    }
}

public class Pramof extends Wesu {
    public byte[] getPesma() {
        ...
    }
}

public class Psesh {
    public List<String> getErUcxid() {
        ...
    }
}

public class Puph {
    public File getAsten() {
        ...
    }

    public List<CesIned> getPecs() {
        ...
    }
}

public class Sengtioc extends Ciul {
    public List<Hangwid> getDiMisis() {
        ...
    }
}

public class Umic extends Edpung {
    public File getCulec() {
        ...
    }
}

public class Wesu {
    public List<String> getEapa() {
        ...
    }
}

public class Wopra {
    public String getNecs() {
        ...
    }

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

    Occiss i

    ...and the following method:

    public void process(byte[] item)

    ...write code to process the ika of the first skebe of the first roale of the first ceMe of i.

    Solution

    for (Hasa ceMe : i.getCalo().getWopra().getCeMesList()) {
        for (Phater roale : ceMe.getIbar().getLaNi().getRoalesList()) {
            for (Sengtioc skebe : roale.getOblo().getSkebesList()) {
                process(skebe.getCiul().getTris().getIka());
            }
        }
    }

Related puzzles: