Class relationships: Correct Solution


Consider the follow class declarations:

public class Aidmond {
    public List<String> getCiDamil() {
        ...
    }
}

public class Boodpo {
    public Nopnant getOrdi() {
        ...
    }

    public int getMaDrel() {
        ...
    }
}

public class Gaunos extends Rewksnem {
    public List<Nombagh> getSuads() {
        ...
    }
}

public class Icro {
    public Sphulec getProsu() {
        ...
    }

    public File getStrin() {
        ...
    }

    public int getHar() {
        ...
    }
}

public class Nombagh {
    public File getMii() {
        ...
    }
}

public class Nopnant {
    public String getHaEash() {
        ...
    }

    public List<Gaunos> getCopus() {
        ...
    }
}

public class Rewksnem extends Aidmond {
    public List<Icro> getDaNens() {
        ...
    }
}

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

    Boodpo kirm

    ...and the following method:

    public void process(int item)

    ...write code to process the har of the first daNen of the first copu of kirm.

    Solution

    for (Gaunos copu : kirm.getOrdi().getCopusList()) {
        for (Icro daNen : copu.getRewksnem().getDaNensList()) {
            process(daNen.getHar());
        }
    }

Related puzzles: