Class relationships: Correct Solution


Consider the follow class declarations:

public class Alscli {
    public File getTix() {
        ...
    }
}

public class Beli {
    public List<Siosmtre> getOlTruls() {
        ...
    }

    public Alscli getSoWeso() {
        ...
    }
}

public class Bemfiwn {
    public List<String> getAlCoute() {
        ...
    }
}

public class Cerchriont {
    public String getMeWosma() {
        ...
    }
}

public class Clossgost {
    public Beli getCipa() {
        ...
    }

    public List<Psoc> getCris() {
        ...
    }
}

public class Crati {
    public List<Cerchriont> getElShiases() {
        ...
    }

    public List<Lasmeent> getHiacs() {
        ...
    }

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

public class Glingcas {
    public File getSirn() {
        ...
    }
}

public class Gosma {
    public int getBaPem() {
        ...
    }

    public Crati getAsBi() {
        ...
    }
}

public class Hungser {
    public Ipro getEaTio() {
        ...
    }

    public Clossgost getDiMisra() {
        ...
    }
}

public class Ipro extends Shethis {
    public byte[] getPead() {
        ...
    }
}

public class Lasmeent {
    public List<Mastil> getFeMotis() {
        ...
    }

    public String getNeMohu() {
        ...
    }
}

public class Mastil {
    public int getOdu() {
        ...
    }
}

public class Ouba {
    public int getAcser() {
        ...
    }
}

public class Pamhic extends Gosma {
    public File getUecem() {
        ...
    }
}

public class Plas extends Ouba {
    public List<Tida> getChors() {
        ...
    }
}

public class Plio extends Puint {
    public File getCiUc() {
        ...
    }
}

public class Proleae {
    public byte[] getScest() {
        ...
    }

    public Plas getErre() {
        ...
    }
}

public class Psoc extends Plio {
    public Bemfiwn getBidan() {
        ...
    }
}

public class Puint extends Glingcas {
    public Shiosi getHeen() {
        ...
    }
}

public class Shethis {
    public File getGilel() {
        ...
    }
}

public class Shiosi {
    public List<Sost> getMibos() {
        ...
    }

    public int getFlac() {
        ...
    }
}

public class Siosmtre {
    public List<String> getTena() {
        ...
    }
}

public class Sost extends Proleae {
    public String getHosto() {
        ...
    }
}

public class Tida {
    public List<Pamhic> getMidzos() {
        ...
    }

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

    Hungser stuc

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the ner of each midzo of the first chor of each mibo of the first cri of stuc.

    Solution

    for (Psoc cri : stuc.getDiMisra().getCrisList()) {
        for (Tida chor : cri.getPlio().getPuint().getHeen().getMibos().get(0).getProleae().getErre().getChorsList()) {
            process(chor.getMidzos().get(0).getGosma().getAsBi().getNer());
        }
    }

Related puzzles: