Class relationships: Correct Solution


Consider the follow class declarations:

public class Braf {
    public List<String> getSemgi() {
        ...
    }
}

public class Cecne extends Braf {
    public List<String> getWiEx() {
        ...
    }

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

public class Chepsten {
    public List<Miskew> getOces() {
        ...
    }

    public List<Osthiand> getAsans() {
        ...
    }
}

public class Cican {
    public Cecne getIngse() {
        ...
    }

    public int getEnmio() {
        ...
    }
}

public class Miskew {
    public List<String> getNiSonu() {
        ...
    }
}

public class Oron extends Cican {
    public List<Plinpin> getTwens() {
        ...
    }
}

public class Osthiand {
    public int getRiEoc() {
        ...
    }

    public Oron getTaPa() {
        ...
    }
}

public class Plinpin {
    public String getBopne() {
        ...
    }
}
  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:

    Chepsten ep

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the penfi of the first asan of ep.

    Solution

    for (Osthiand asan : ep.getAsansList()) {
        process(asan.getTaPa().getCican().getIngse().getPenfi());
    }

Related puzzles: