Class relationships: Correct Solution


Consider the follow class declarations:

public class AanXoc extends Fiont {
    public int getPrip() {
        ...
    }
}

public class Aont {
    public int getGran() {
        ...
    }
}

public class Ascess extends Sesmdirm {
    public String getGea() {
        ...
    }
}

public class Asspolm {
    public Tanches getSoSiort() {
        ...
    }

    public List<Inash> getGecs() {
        ...
    }
}

public class Crerpe {
    public String getReIat() {
        ...
    }
}

public class Esmshod extends Orus {
    public byte[] getOng() {
        ...
    }
}

public class Essu {
    public List<Scon> getLibens() {
        ...
    }

    public List<Viomqid> getTurjos() {
        ...
    }
}

public class Fiont {
    public Keli getMual() {
        ...
    }

    public int getMonch() {
        ...
    }
}

public class Inash {
    public List<Qaphpe> getDiris() {
        ...
    }

    public byte[] getSiEird() {
        ...
    }
}

public class Keli extends Essu {
    public List<Aont> getThacs() {
        ...
    }
}

public class Milu {
    public byte[] getEtOs() {
        ...
    }

    public Sicin getWeSu() {
        ...
    }
}

public class Orus {
    public int getCaWhesm() {
        ...
    }
}

public class OshRicang {
    public byte[] getSeFlad() {
        ...
    }
}

public class Pershess {
    public File getEtra() {
        ...
    }
}

public class Qaphpe {
    public List<String> getHeni() {
        ...
    }
}

public class Scon {
    public List<Ascess> getOrms() {
        ...
    }

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

public class Secjea extends SioTre {
    public List<String> getGrer() {
        ...
    }

    public int getVoAstad() {
        ...
    }
}

public class Sesmdirm {
    public Esmshod getAnu() {
        ...
    }

    public Secjea getAhard() {
        ...
    }
}

public class Sicin extends Crerpe {
    public Pershess getIaiol() {
        ...
    }

    public Sonbu getFal() {
        ...
    }

    public List<AanXoc> getDaEls() {
        ...
    }
}

public class SioTre {
    public List<String> getStral() {
        ...
    }
}

public class Sonbu {
    public OshRicang getMuNiant() {
        ...
    }

    public int getDedpu() {
        ...
    }
}

public class Tanches extends Milu {
    public String getErAs() {
        ...
    }
}

public class Viomqid {
    public List<String> getRarm() {
        ...
    }
}

public class Zair {
    public int getPel() {
        ...
    }

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

    Zair il

    ...and the following method:

    public void process(int item)

    ...write code to process the voAstad of the first orm of each liben of the first daEl of the first nuShis of il.

    Solution

    for (Asspolm nuShis : il.getNuShisesList()) {
        for (AanXoc daEl : nuShis.getSoSiort().getMilu().getWeSu().getDaElsList()) {
            for (Ascess orm : daEl.getFiont().getMual().getEssu().getLibens().get(0).getOrmsList()) {
                process(orm.getSesmdirm().getAhard().getVoAstad());
            }
        }
    }

Related puzzles: