Class relationships: Correct Solution


Consider the follow class declarations:

public class Eace {
    public byte[] getRaBri() {
        ...
    }

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

public class Greepe {
    public File getOdi() {
        ...
    }

    public List<Volpe> getBrels() {
        ...
    }
}

public class Lingne {
    public byte[] getIore() {
        ...
    }
}

public class Muoc {
    public String getPuk() {
        ...
    }

    public List<OssTuso> getIdias() {
        ...
    }
}

public class Nioci {
    public Shitan getSti() {
        ...
    }

    public Satim getMoNio() {
        ...
    }
}

public class Niwas extends Lingne {
    public List<Nioci> getGnas() {
        ...
    }
}

public class OssTuso {
    public File getCosre() {
        ...
    }
}

public class Phor {
    public byte[] getPesou() {
        ...
    }
}

public class Prissla {
    public File getCiNi() {
        ...
    }
}

public class Satim {
    public Tecro getOnCil() {
        ...
    }

    public List<UntPiopcia> getEdefs() {
        ...
    }

    public Phor getTaBlass() {
        ...
    }
}

public class Shitan {
    public String getMeEn() {
        ...
    }
}

public class Skutrom extends Eace {
    public List<String> getPalic() {
        ...
    }
}

public class Stintcia extends Niwas {
    public List<Prissla> getAsics() {
        ...
    }

    public Muoc getUntpo() {
        ...
    }
}

public class Tecro extends Greepe {
    public File getStess() {
        ...
    }
}

public class UntPiopcia {
    public int getKhai() {
        ...
    }
}

public class Volpe {
    public List<Skutrom> getRieeses() {
        ...
    }

    public File getHapoo() {
        ...
    }
}
  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:

    Stintcia wru

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the snirm of each riees of the first brel of the first gna of wru.

    Solution

    for (Nioci gna : wru.getNiwas().getGnasList()) {
        for (Volpe brel : gna.getMoNio().getOnCil().getGreepe().getBrelsList()) {
            process(brel.getRieeses().get(0).getEace().getSnirm());
        }
    }

Related puzzles: