Class relationships: Correct Solution


Consider the follow class declarations:

public class Barlant {
    public String getThesm() {
        ...
    }

    public List<Dioci> getEiots() {
        ...
    }
}

public class Dioci {
    public byte[] getOcal() {
        ...
    }

    public Lesm getSorm() {
        ...
    }
}

public class EgeDetch extends Barlant {
    public File getRaId() {
        ...
    }
}

public class Grinin {
    public int getResel() {
        ...
    }
}

public class Irwie {
    public byte[] getDeSi() {
        ...
    }

    public RerCopdou getThang() {
        ...
    }
}

public class Isced {
    public int getArph() {
        ...
    }
}

public class Lesm extends Irwie {
    public List<Tunhall> getCusases() {
        ...
    }
}

public class Moussror {
    public File getVoIr() {
        ...
    }
}

public class OssPlecic extends Moussror {
    public List<Pragh> getSpres() {
        ...
    }
}

public class Pragh {
    public int getZiar() {
        ...
    }
}

public class RerCopdou {
    public Xirgling getCed() {
        ...
    }

    public List<Zang> getChus() {
        ...
    }
}

public class RurPruot {
    public File getDuas() {
        ...
    }

    public List<Isced> getStroxs() {
        ...
    }

    public String getMoes() {
        ...
    }
}

public class Stelkmes extends Grinin {
    public RurPruot getPoc() {
        ...
    }

    public OssPlecic getOsa() {
        ...
    }
}

public class Tunhall {
    public File getNac() {
        ...
    }
}

public class Xirgling {
    public int getPiQie() {
        ...
    }
}

public class Zang extends Stelkmes {
    public String getRoos() {
        ...
    }
}
  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:

    EgeDetch duk

    ...and the following method:

    public void process(String item)

    ...write code to process the moes of the first chu of each eiot of duk.

    Solution

    for (Zang chu : duk.getBarlant().getEiots().get(0).getSorm().getIrwie().getThang().getChusList()) {
        process(chu.getStelkmes().getPoc().getMoes());
    }

Related puzzles: