Class relationships: Correct Solution


Consider the follow class declarations:

public class Brustgri {
    public String getSloi() {
        ...
    }
}

public class Cossin {
    public List<Psilu> getPsars() {
        ...
    }

    public String getPeax() {
        ...
    }
}

public class Couo {
    public String getPucsi() {
        ...
    }
}

public class Covo {
    public Gorji getSniac() {
        ...
    }

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

public class Ferlian {
    public String getCiot() {
        ...
    }
}

public class Gorji {
    public String getIac() {
        ...
    }
}

public class Gorma {
    public String getHiou() {
        ...
    }

    public List<Prosssor> getFres() {
        ...
    }
}

public class Nudass extends Gorma {
    public byte[] getSut() {
        ...
    }
}

public class OpuPliat {
    public String getBrau() {
        ...
    }
}

public class Paia {
    public Pnion getSiOd() {
        ...
    }

    public List<Couo> getMaswes() {
        ...
    }
}

public class Pimdost extends Brustgri {
    public Paia getSioss() {
        ...
    }

    public List<Sifi> getOros() {
        ...
    }
}

public class Pnion {
    public byte[] getFuInen() {
        ...
    }
}

public class Posen extends Ferlian {
    public Cossin getAng() {
        ...
    }
}

public class Prainteir {
    public byte[] getDaEl() {
        ...
    }
}

public class Prosssor {
    public Pimdost getApIp() {
        ...
    }

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

public class Psilu {
    public List<Covo> getIwQamifs() {
        ...
    }

    public Trajeck getPhe() {
        ...
    }
}

public class Sifi extends Slou {
    public List<String> getChred() {
        ...
    }
}

public class Slou {
    public ZecAsint getKaGo() {
        ...
    }

    public List<OpuPliat> getGreres() {
        ...
    }
}

public class Trajeck {
    public List<String> getCifbi() {
        ...
    }

    public String getKirou() {
        ...
    }
}

public class ZecAsint extends Posen {
    public List<Prainteir> getCioars() {
        ...
    }
}
  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:

    Nudass fa

    ...and the following method:

    public void process(String item)

    ...write code to process the kirou of the first psar of the first oro of each fre of fa.

    Solution

    for (Sifi oro : fa.getGorma().getFres().get(0).getApIp().getOrosList()) {
        for (Psilu psar : oro.getSlou().getKaGo().getPosen().getAng().getPsarsList()) {
            process(psar.getPhe().getKirou());
        }
    }

Related puzzles: