Class relationships: Correct Solution


Consider the follow class declarations:

public class Bosgrud {
    public Coshfint getOsen() {
        ...
    }

    public List<NenSocot> getSclises() {
        ...
    }
}

public class Coshfint extends Stapan {
    public String getHian() {
        ...
    }
}

public class Meste {
    public Saddio getHaRo() {
        ...
    }

    public int getLient() {
        ...
    }
}

public class Midep {
    public List<String> getFeRhess() {
        ...
    }
}

public class Nelta {
    public String getAdEngri() {
        ...
    }
}

public class NenSocot extends Midep {
    public Nelta getCiopt() {
        ...
    }
}

public class Psoun {
    public String getPuDahen() {
        ...
    }
}

public class Saddio {
    public String getUcPhoar() {
        ...
    }

    public String getBiJo() {
        ...
    }
}

public class Stapan extends Meste {
    public List<Psoun> getChirs() {
        ...
    }
}

public class Swerda {
    public List<Bosgrud> getTaAnpeses() {
        ...
    }

    public List<String> getIoan() {
        ...
    }
}
  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:

    Swerda po

    ...and the following method:

    public void process(String item)

    ...write code to process the biJo of the first taAnpes of po.

    Solution

    for (Bosgrud taAnpes : po.getTaAnpesesList()) {
        process(taAnpes.getOsen().getStapan().getMeste().getHaRo().getBiJo());
    }

Related puzzles: