Class relationships: Correct Solution


Consider the follow class declarations:

public class Chie extends Jastes {
    public IrnWantmi getTaso() {
        ...
    }
}

public class Fretgo {
    public int getUsIa() {
        ...
    }
}

public class Hiadnec {
    public Chie getZas() {
        ...
    }

    public List<Nengbas> getHioris() {
        ...
    }
}

public class IrnWantmi {
    public File getBross() {
        ...
    }

    public String getIdbal() {
        ...
    }
}

public class Jastes {
    public File getFras() {
        ...
    }
}

public class Medhix extends Hiadnec {
    public String getNecle() {
        ...
    }
}

public class Nengbas {
    public byte[] getOlri() {
        ...
    }
}

public class Stia extends Fretgo {
    public List<Medhix> getEchlus() {
        ...
    }
}
  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:

    Stia bru

    ...and the following method:

    public void process(String item)

    ...write code to process the idbal of the first echlu of bru.

    Solution

    for (Medhix echlu : bru.getEchlusList()) {
        process(echlu.getHiadnec().getZas().getTaso().getIdbal());
    }

Related puzzles: