Class relationships: Correct Solution


Consider the follow class declarations:

public class Birtlin {
    public Phiss getIod() {
        ...
    }

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

public class Cheess {
    public List<Coisen> getTeMoens() {
        ...
    }

    public Modsphuc getHuoun() {
        ...
    }
}

public class Coisen {
    public int getCori() {
        ...
    }

    public Spoi getQahix() {
        ...
    }
}

public class Dirtsesm {
    public Sprir getIdcio() {
        ...
    }

    public List<PhaDortbrack> getBedans() {
        ...
    }
}

public class Donclai {
    public byte[] getCalda() {
        ...
    }
}

public class Fostush {
    public int getOela() {
        ...
    }
}

public class Geen extends Wulduod {
    public byte[] getOiShid() {
        ...
    }
}

public class Leptiom {
    public List<String> getAdMashe() {
        ...
    }
}

public class Lirfeous {
    public Spelar getBaPem() {
        ...
    }

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

public class Midtha {
    public Puint getPrax() {
        ...
    }

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

public class Miutpa {
    public int getSeOd() {
        ...
    }

    public Dirtsesm getQess() {
        ...
    }
}

public class Modsphuc extends Donclai {
    public Birtlin getCein() {
        ...
    }
}

public class Naltwa {
    public int getOrIsmo() {
        ...
    }

    public Geen getGaUrhan() {
        ...
    }
}

public class PhaDortbrack {
    public byte[] getOmi() {
        ...
    }

    public List<Leptiom> getArStis() {
        ...
    }

    public String getChroe() {
        ...
    }
}

public class Phiss {
    public String getSuwn() {
        ...
    }
}

public class Puint {
    public int getMerne() {
        ...
    }
}

public class Sirpsi {
    public List<Stic> getTrols() {
        ...
    }

    public List<Fostush> getGrars() {
        ...
    }
}

public class Spelar extends Naltwa {
    public byte[] getLosm() {
        ...
    }
}

public class Speren extends Miutpa {
    public List<String> getBeClel() {
        ...
    }
}

public class Spoi extends Wirmro {
    public int getPruc() {
        ...
    }
}

public class Sprir extends Sirpsi {
    public byte[] getOshme() {
        ...
    }
}

public class Stic {
    public String getEnlir() {
        ...
    }
}

public class Wirmro {
    public List<Lirfeous> getHeCus() {
        ...
    }

    public List<Midtha> getStrecs() {
        ...
    }
}

public class Wulduod {
    public List<Speren> getEhus() {
        ...
    }

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

    Cheess fla

    ...and the following method:

    public void process(String item)

    ...write code to process the chroe of each bedan of the first ehu of each heCu of each teMoen of fla.

    Solution

    for (Speren ehu : fla.getTeMoens().get(0).getQahix().getWirmro().getHeCus().get(0).getBaPem().getNaltwa().getGaUrhan().getWulduod().getEhusList()) {
        process(ehu.getMiutpa().getQess().getBedans().get(0).getChroe());
    }

Related puzzles: