Class relationships: Correct Solution


Consider the follow class declarations:

public class Arcesm {
    public byte[] getFiap() {
        ...
    }
}

public class Cafrit {
    public int getFous() {
        ...
    }

    public List<Sotount> getIrdecs() {
        ...
    }
}

public class Facan {
    public List<Cafrit> getPoPis() {
        ...
    }

    public List<Noell> getTaIns() {
        ...
    }
}

public class Geec {
    public String getHolar() {
        ...
    }
}

public class Heglad extends Sotstrool {
    public Strosspe getMism() {
        ...
    }

    public Stildu getIlOrm() {
        ...
    }
}

public class Hopmest extends Rirbust {
    public byte[] getRiaw() {
        ...
    }
}

public class Maupool {
    public File getGaMerm() {
        ...
    }
}

public class Noell {
    public byte[] getCoIphbe() {
        ...
    }
}

public class Pritliol {
    public List<Arcesm> getSePasms() {
        ...
    }

    public File getEced() {
        ...
    }

    public String getStapt() {
        ...
    }
}

public class Rirbust {
    public int getIgla() {
        ...
    }

    public Facan getInoss() {
        ...
    }
}

public class Safa {
    public byte[] getPhlon() {
        ...
    }

    public List<Geec> getRedins() {
        ...
    }
}

public class Seckic extends Pritliol {
    public String getCocs() {
        ...
    }
}

public class Sotount {
    public Safa getTidia() {
        ...
    }

    public Heglad getSast() {
        ...
    }
}

public class Sotstrool {
    public List<String> getRosh() {
        ...
    }

    public List<Seckic> getCaPas() {
        ...
    }
}

public class Stildu extends Maupool {
    public String getWana() {
        ...
    }
}

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

    Hopmest kise

    ...and the following method:

    public void process(String item)

    ...write code to process the stapt of the first caPa of the first irdec of the first poPi of kise.

    Solution

    for (Cafrit poPi : kise.getRirbust().getInoss().getPoPisList()) {
        for (Sotount irdec : poPi.getIrdecsList()) {
            for (Seckic caPa : irdec.getSast().getSotstrool().getCaPasList()) {
                process(caPa.getPritliol().getStapt());
            }
        }
    }

Related puzzles: