Class relationships: Correct Solution


Consider the follow class declarations:

public class Apir extends Bilan {
    public List<Peion> getCestus() {
        ...
    }
}

public class Banerch extends NokJes {
    public Idphood getGudo() {
        ...
    }
}

public class Bilan {
    public int getMoje() {
        ...
    }
}

public class CimClesac extends Iashtro {
    public List<Harkblon> getAdEls() {
        ...
    }

    public List<Imil> getReDuzzs() {
        ...
    }
}

public class Decob {
    public String getNiPel() {
        ...
    }
}

public class Harkblon {
    public List<String> getEcs() {
        ...
    }
}

public class Iashtro {
    public List<String> getKoPoirt() {
        ...
    }
}

public class Idphood {
    public Decob getPsu() {
        ...
    }

    public int getCota() {
        ...
    }
}

public class Imil {
    public int getOiEdro() {
        ...
    }

    public Banerch getAgnu() {
        ...
    }
}

public class Litzfia {
    public List<String> getOss() {
        ...
    }

    public Prumo getNocid() {
        ...
    }
}

public class NokJes {
    public List<Litzfia> getBeMos() {
        ...
    }

    public String getThrao() {
        ...
    }
}

public class Peion {
    public String getArEsa() {
        ...
    }

    public Thedret getAusm() {
        ...
    }

    public String getGaLul() {
        ...
    }
}

public class Prumo extends Apir {
    public List<String> getFliim() {
        ...
    }
}

public class Thedret {
    public int getToAn() {
        ...
    }
}
  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:

    CimClesac fe

    ...and the following method:

    public void process(String item)

    ...write code to process the gaLul of the first cestu of the first beMo of the first reDuzz of fe.

    Solution

    for (Imil reDuzz : fe.getReDuzzsList()) {
        for (Litzfia beMo : reDuzz.getAgnu().getNokJes().getBeMosList()) {
            for (Peion cestu : beMo.getNocid().getApir().getCestusList()) {
                process(cestu.getGaLul());
            }
        }
    }

Related puzzles: