Class relationships: Correct Solution


Consider the follow class declarations:

public class GocDopail {
    public Xaer getChru() {
        ...
    }

    public Loctis getHoBe() {
        ...
    }
}

public class Hencoct {
    public byte[] getOrci() {
        ...
    }
}

public class Hess {
    public byte[] getHar() {
        ...
    }

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

public class Houst {
    public File getCrio() {
        ...
    }
}

public class Lesdir extends Nish {
    public GocDopail getRese() {
        ...
    }
}

public class Loctis {
    public List<String> getNiont() {
        ...
    }

    public List<Hencoct> getImOnmars() {
        ...
    }
}

public class Losgin extends Stusdin {
    public String getLenam() {
        ...
    }
}

public class Nish {
    public int getBedpo() {
        ...
    }
}

public class OssPortos {
    public List<Slis> getCeBopos() {
        ...
    }

    public int getCoc() {
        ...
    }
}

public class Padu {
    public Pligrec getCiIo() {
        ...
    }

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

public class Pligrec {
    public byte[] getUnLaa() {
        ...
    }

    public List<Scrio> getIceshs() {
        ...
    }
}

public class Scrio extends OssPortos {
    public List<String> getFrene() {
        ...
    }
}

public class Sienbors {
    public int getCil() {
        ...
    }
}

public class Slis extends Lesdir {
    public List<Houst> getSanbos() {
        ...
    }
}

public class Stusdin {
    public int getPle() {
        ...
    }

    public Sienbors getPormi() {
        ...
    }
}

public class Xaer extends Losgin {
    public List<Hess> getPoOungs() {
        ...
    }
}
  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:

    Padu rur

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the pse of each poOung of the first ceBopo of the first icesh of rur.

    Solution

    for (Scrio icesh : rur.getCiIo().getIceshsList()) {
        for (Slis ceBopo : icesh.getOssPortos().getCeBoposList()) {
            process(ceBopo.getLesdir().getRese().getChru().getPoOungs().get(0).getPse());
        }
    }

Related puzzles: