Class relationships: Correct Solution


Consider the follow class declarations:

public class Bocend {
    public String getDant() {
        ...
    }

    public Corosh getNaEo() {
        ...
    }
}

public class Chea {
    public List<String> getClal() {
        ...
    }
}

public class Corosh {
    public List<String> getSnoni() {
        ...
    }
}

public class Crimet extends Iortrol {
    public Onge getPsior() {
        ...
    }
}

public class Desmess {
    public List<Doumec> getSpos() {
        ...
    }

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

public class Doumec {
    public byte[] getDuHurch() {
        ...
    }

    public int getNocs() {
        ...
    }
}

public class Hepsing {
    public byte[] getIiBic() {
        ...
    }
}

public class Iortrol {
    public Tadi getPedo() {
        ...
    }

    public int getAcfa() {
        ...
    }
}

public class Lerdco {
    public List<Crimet> getTrosts() {
        ...
    }

    public List<Salhur> getCiIdros() {
        ...
    }

    public List<Chea> getMoIses() {
        ...
    }
}

public class Onge {
    public List<String> getFlol() {
        ...
    }

    public Hepsing getAnsum() {
        ...
    }
}

public class OroSontflel {
    public Lerdco getIoght() {
        ...
    }

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

public class Rareel extends Bocend {
    public List<Desmess> getHoEacs() {
        ...
    }
}

public class Salhur {
    public String getOgImaer() {
        ...
    }
}

public class Tadi extends Rareel {
    public byte[] getAbre() {
        ...
    }
}
  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:

    OroSontflel re

    ...and the following method:

    public void process(int item)

    ...write code to process the nocs of each spo of the first hoEac of the first trost of re.

    Solution

    for (Crimet trost : re.getIoght().getTrostsList()) {
        for (Desmess hoEac : trost.getIortrol().getPedo().getRareel().getHoEacsList()) {
            process(hoEac.getSpos().get(0).getNocs());
        }
    }

Related puzzles: