Class relationships: Correct Solution


Consider the follow class declarations:

public class BiaXithgre {
    public String getNiss() {
        ...
    }

    public String getEzad() {
        ...
    }
}

public class CelHogre {
    public byte[] getIrman() {
        ...
    }
}

public class Cirphrith extends Risuem {
    public List<Hissce> getSurms() {
        ...
    }
}

public class Degil {
    public int getOuEch() {
        ...
    }
}

public class Distcunt {
    public Degil getFelme() {
        ...
    }

    public List<BiaXithgre> getParms() {
        ...
    }
}

public class Habrelt extends Cirphrith {
    public List<Plednes> getOases() {
        ...
    }

    public List<CelHogre> getMucs() {
        ...
    }
}

public class Hissce {
    public int getGeOs() {
        ...
    }

    public Distcunt getIcEnem() {
        ...
    }
}

public class Masssem {
    public Habrelt getCaErad() {
        ...
    }

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

public class Plednes {
    public byte[] getHar() {
        ...
    }
}

public class Risuem {
    public List<String> getSitan() {
        ...
    }
}
  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:

    Masssem ex

    ...and the following method:

    public void process(String item)

    ...write code to process the ezad of each parm of the first surm of ex.

    Solution

    for (Hissce surm : ex.getCaErad().getCirphrith().getSurmsList()) {
        process(surm.getIcEnem().getParms().get(0).getEzad());
    }

Related puzzles: