Class relationships: Correct Solution


Consider the follow class declarations:

public class Anhai {
    public List<Theng> getPhaihs() {
        ...
    }

    public int getBrihi() {
        ...
    }
}

public class Anmel {
    public Sesm getWosh() {
        ...
    }

    public List<GluPlaxpoid> getKaners() {
        ...
    }
}

public class Diclou {
    public String getElBuid() {
        ...
    }
}

public class GluPlaxpoid {
    public byte[] getShao() {
        ...
    }

    public File getImic() {
        ...
    }
}

public class Ingsil {
    public byte[] getEdCeuo() {
        ...
    }
}

public class Loncae extends Anmel {
    public Diclou getPris() {
        ...
    }
}

public class Oriac extends Loncae {
    public String getOnTo() {
        ...
    }
}

public class Sesm {
    public String getTodvo() {
        ...
    }
}

public class Theng {
    public Oriac getSuNonca() {
        ...
    }

    public List<TroBiar> getHiseds() {
        ...
    }

    public List<Ingsil> getEchias() {
        ...
    }
}

public class TroBiar {
    public File getMeeng() {
        ...
    }
}
  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:

    Anhai tist

    ...and the following method:

    public void process(File item)

    ...write code to process the imic of the first kaner of the first phaih of tist.

    Solution

    for (Theng phaih : tist.getPhaihsList()) {
        for (GluPlaxpoid kaner : phaih.getSuNonca().getLoncae().getAnmel().getKanersList()) {
            process(kaner.getImic());
        }
    }

Related puzzles: