Class relationships: Correct Solution


Consider the follow class declarations:

public class Aswir {
    public List<Iopa> getChres() {
        ...
    }

    public int getElRoae() {
        ...
    }
}

public class Bectrou {
    public List<String> getItex() {
        ...
    }
}

public class Broc extends Slosi {
    public Stict getNodin() {
        ...
    }
}

public class Cenkeng {
    public List<Efrald> getOsVens() {
        ...
    }

    public String getPriin() {
        ...
    }

    public String getCrue() {
        ...
    }
}

public class Ectmor {
    public File getQuAnfir() {
        ...
    }
}

public class Efrald {
    public int getHiad() {
        ...
    }
}

public class Iopa extends Broc {
    public Salmewth getSunie() {
        ...
    }
}

public class Miastlet extends Swactrat {
    public String getDaTwe() {
        ...
    }
}

public class Odstia {
    public List<String> getActra() {
        ...
    }

    public Pemist getDant() {
        ...
    }
}

public class Oldurk {
    public byte[] getVePlil() {
        ...
    }
}

public class Pemist {
    public int getAmCi() {
        ...
    }

    public List<Aswir> getRiards() {
        ...
    }
}

public class Peoa {
    public List<String> getPreso() {
        ...
    }
}

public class Rian extends Odstia {
    public int getIlPhess() {
        ...
    }
}

public class Salmewth {
    public Peoa getPonu() {
        ...
    }

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

public class SleIss {
    public byte[] getHiSpua() {
        ...
    }
}

public class Slosi {
    public List<String> getCla() {
        ...
    }
}

public class Stict extends SleIss {
    public Miastlet getLaRuaco() {
        ...
    }
}

public class Swactrat {
    public List<Bectrou> getScas() {
        ...
    }

    public List<Cenkeng> getGatris() {
        ...
    }

    public Oldurk getUsIssi() {
        ...
    }

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

    Rian ne

    ...and the following method:

    public void process(String item)

    ...write code to process the crue of the first gatri of the first chre of the first riard of ne.

    Solution

    for (Aswir riard : ne.getOdstia().getDant().getRiardsList()) {
        for (Iopa chre : riard.getChresList()) {
            for (Cenkeng gatri : chre.getBroc().getNodin().getLaRuaco().getSwactrat().getGatrisList()) {
                process(gatri.getCrue());
            }
        }
    }

Related puzzles: