Class relationships: Correct Solution


Consider the follow class declarations:

public class Copam {
    public int getPolpe() {
        ...
    }
}

public class Dethi {
    public File getCaEs() {
        ...
    }

    public String getCuwa() {
        ...
    }
}

public class Maenga {
    public List<Tosdrarst> getCils() {
        ...
    }

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

public class Poam {
    public byte[] getIsEa() {
        ...
    }
}

public class SooPhomlo extends Maenga {
    public byte[] getEuWaceo() {
        ...
    }
}

public class Spaba extends Copam {
    public List<Dethi> getModbis() {
        ...
    }

    public Poam getHigu() {
        ...
    }
}

public class Tosdrarst {
    public Wesm getTenga() {
        ...
    }

    public Spaba getChaic() {
        ...
    }
}

public class Wesm {
    public byte[] getRard() {
        ...
    }
}
  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:

    SooPhomlo ciro

    ...and the following method:

    public void process(String item)

    ...write code to process the cuwa of the first modbi of each cil of ciro.

    Solution

    for (Dethi modbi : ciro.getMaenga().getCils().get(0).getChaic().getModbisList()) {
        process(modbi.getCuwa());
    }

Related puzzles: