Class relationships: Correct Solution


Consider the follow class declarations:

public class AodWoted {
    public byte[] getNes() {
        ...
    }

    public OetKedme getIod() {
        ...
    }
}

public class Hotrir extends Spioss {
    public String getPhud() {
        ...
    }
}

public class Kics {
    public String getSeBe() {
        ...
    }
}

public class OetKedme {
    public int getCearu() {
        ...
    }

    public List<Pramfia> getFiSeluns() {
        ...
    }
}

public class Osal extends Swent {
    public List<Zarm> getOsses() {
        ...
    }
}

public class Pamet {
    public List<Trafroi> getWhoses() {
        ...
    }

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

public class Pramfia {
    public String getAnSqe() {
        ...
    }

    public File getHos() {
        ...
    }
}

public class Spioss {
    public int getCiIl() {
        ...
    }
}

public class Swent extends Tiasirst {
    public Pamet getNiem() {
        ...
    }
}

public class Tiasirst {
    public List<String> getHioh() {
        ...
    }
}

public class Trafroi extends AodWoted {
    public List<Kics> getMePras() {
        ...
    }

    public Hotrir getRor() {
        ...
    }
}

public class Zarm {
    public File getOrCim() {
        ...
    }
}
  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:

    Osal ipes

    ...and the following method:

    public void process(File item)

    ...write code to process the hos of the first fiSelun of the first whos of ipes.

    Solution

    for (Trafroi whos : ipes.getSwent().getNiem().getWhosesList()) {
        for (Pramfia fiSelun : whos.getAodWoted().getIod().getFiSelunsList()) {
            process(fiSelun.getHos());
        }
    }

Related puzzles: