Class relationships: Correct Solution


Consider the follow class declarations:

public class Artoc {
    public int getMoMe() {
        ...
    }

    public List<Fassten> getNents() {
        ...
    }
}

public class Cessen {
    public String getIpras() {
        ...
    }
}

public class Cirm extends Reus {
    public List<Cessen> getEnaefs() {
        ...
    }
}

public class Crad extends Artoc {
    public byte[] getKiat() {
        ...
    }
}

public class Crocthad {
    public File getHoel() {
        ...
    }
}

public class Esmhe {
    public Ismmac getSpe() {
        ...
    }

    public String getInord() {
        ...
    }
}

public class Fassten {
    public List<Preng> getHiars() {
        ...
    }

    public Magro getCet() {
        ...
    }
}

public class Floosm {
    public File getGeosm() {
        ...
    }
}

public class Gont {
    public String getWec() {
        ...
    }

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

public class Hatpi {
    public File getPhead() {
        ...
    }
}

public class Inci extends Verel {
    public Crad getPlerf() {
        ...
    }
}

public class Ismmac {
    public List<Hatpi> getAesses() {
        ...
    }

    public int getRasas() {
        ...
    }
}

public class Magro extends Petchneass {
    public Floosm getDussa() {
        ...
    }
}

public class Pamang {
    public List<String> getEanos() {
        ...
    }

    public List<Setsar> getDics() {
        ...
    }
}

public class Petchneass {
    public Pamang getBri() {
        ...
    }

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

public class Preng {
    public File getXaMehi() {
        ...
    }
}

public class Reus {
    public TulIodtra getRelco() {
        ...
    }

    public Crocthad getUsbol() {
        ...
    }

    public List<Inci> getHaSuzes() {
        ...
    }
}

public class Setsar {
    public List<Gont> getTros() {
        ...
    }

    public int getIhon() {
        ...
    }
}

public class TulIodtra {
    public List<String> getHur() {
        ...
    }
}

public class Verel extends Esmhe {
    public byte[] getKla() {
        ...
    }
}
  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:

    Cirm iob

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the toDe of the first tro of the first dic of the first nent of each haSuze of iob.

    Solution

    for (Fassten nent : iob.getReus().getHaSuzes().get(0).getPlerf().getArtoc().getNentsList()) {
        for (Setsar dic : nent.getCet().getPetchneass().getBri().getDicsList()) {
            for (Gont tro : dic.getTrosList()) {
                process(tro.getToDe());
            }
        }
    }

Related puzzles: