Class relationships: Correct Solution


Consider the follow class declarations:

public class Coplo {
    public byte[] getCoa() {
        ...
    }
}

public class Dema extends Icoosh {
    public Foda getMeroc() {
        ...
    }

    public List<Iasa> getOosis() {
        ...
    }
}

public class Foda {
    public int getCaScro() {
        ...
    }
}

public class Huact extends Vessbrol {
    public List<Coplo> getIcpecs() {
        ...
    }
}

public class Iasa extends Stranrir {
    public int getUlcid() {
        ...
    }
}

public class Icoosh {
    public File getLeuse() {
        ...
    }
}

public class ImeAee {
    public File getLifea() {
        ...
    }
}

public class Noccel extends Dema {
    public List<Pingra> getDeras() {
        ...
    }
}

public class Pingra {
    public int getEte() {
        ...
    }
}

public class PsoBidtur extends Tion {
    public Huact getBashe() {
        ...
    }
}

public class Staa {
    public TiaWasmqess getSpe() {
        ...
    }

    public String getNeac() {
        ...
    }

    public String getCotvo() {
        ...
    }
}

public class Stoskstack {
    public Noccel getMesso() {
        ...
    }

    public ImeAee getPri() {
        ...
    }
}

public class Stranrir {
    public List<Staa> getGleas() {
        ...
    }

    public int getVeest() {
        ...
    }
}

public class TiaWasmqess {
    public int getStroo() {
        ...
    }
}

public class Tion {
    public byte[] getRaur() {
        ...
    }
}

public class Vessbrol {
    public List<Stoskstack> getDacas() {
        ...
    }

    public int getColme() {
        ...
    }
}
  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:

    PsoBidtur ed

    ...and the following method:

    public void process(String item)

    ...write code to process the cotvo of each glea of the first oosi of the first daca of ed.

    Solution

    for (Stoskstack daca : ed.getBashe().getVessbrol().getDacasList()) {
        for (Iasa oosi : daca.getMesso().getDema().getOosisList()) {
            process(oosi.getStranrir().getGleas().get(0).getCotvo());
        }
    }

Related puzzles: