Class relationships: Correct Solution


Consider the follow class declarations:

public class Cathrors {
    public List<String> getElKar() {
        ...
    }
}

public class Criha {
    public int getRoct() {
        ...
    }

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

public class EecRasut extends Irble {
    public int getEep() {
        ...
    }
}

public class Enfed {
    public List<TocEchon> getOtNions() {
        ...
    }

    public List<EecRasut> getEsms() {
        ...
    }
}

public class Irble extends Osad {
    public Criha getUpuir() {
        ...
    }

    public Cathrors getLaa() {
        ...
    }
}

public class Mecdru extends Salstu {
    public List<Psurel> getNaros() {
        ...
    }
}

public class Osad {
    public String getMie() {
        ...
    }
}

public class Psurel {
    public List<String> getDuMi() {
        ...
    }
}

public class Salstu {
    public int getIdial() {
        ...
    }

    public Enfed getAcCa() {
        ...
    }
}

public class TocEchon {
    public String getOciom() {
        ...
    }
}
  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:

    Mecdru pe

    ...and the following method:

    public void process(List<String> item)

    ...write code to process the udin of the first esm of pe.

    Solution

    for (EecRasut esm : pe.getSalstu().getAcCa().getEsmsList()) {
        process(esm.getIrble().getUpuir().getUdin());
    }

Related puzzles: