Class relationships: Correct Solution


Consider the follow class declarations:

public class Anhol {
    public List<String> getPoFli() {
        ...
    }
}

public class Baea {
    public List<OndGida> getEsHillis() {
        ...
    }

    public String getDumac() {
        ...
    }
}

public class EacGepic {
    public List<String> getScu() {
        ...
    }
}

public class Nidlod extends Baea {
    public Soosdur getPeOo() {
        ...
    }
}

public class OndGida extends Anhol {
    public Rosi getIsspu() {
        ...
    }
}

public class Pechuen {
    public String getSti() {
        ...
    }

    public List<EacGepic> getStels() {
        ...
    }
}

public class Plin {
    public int getUldig() {
        ...
    }
}

public class Ralben {
    public List<Rintal> getHaEnpofs() {
        ...
    }

    public int getTodi() {
        ...
    }
}

public class Rintal extends Pechuen {
    public Nidlod getNablu() {
        ...
    }

    public List<Plin> getRaHenis() {
        ...
    }
}

public class Rosi {
    public int getZioc() {
        ...
    }

    public int getPiiin() {
        ...
    }
}

public class Siake extends Ralben {
    public List<String> getDaSeda() {
        ...
    }
}

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

    Siake pel

    ...and the following method:

    public void process(int item)

    ...write code to process the piiin of each esHilli of the first haEnpof of pel.

    Solution

    for (Rintal haEnpof : pel.getRalben().getHaEnpofsList()) {
        process(haEnpof.getNablu().getBaea().getEsHillis().get(0).getIsspu().getPiiin());
    }

Related puzzles: