Class relationships: Correct Solution


Consider the follow class declarations:

public class Atha {
    public int getPedtu() {
        ...
    }
}

public class Balad {
    public File getOntle() {
        ...
    }
}

public class CleCossni extends Kalha {
    public File getSul() {
        ...
    }
}

public class Curiol {
    public Droc getIdIshre() {
        ...
    }

    public List<CleCossni> getUpsirs() {
        ...
    }

    public List<Gint> getRoJescos() {
        ...
    }
}

public class Dismer extends PriHise {
    public String getFeneo() {
        ...
    }

    public int getPoTiruc() {
        ...
    }
}

public class Droc {
    public int getTuTre() {
        ...
    }
}

public class Duar {
    public List<Balad> getEdAsus() {
        ...
    }

    public byte[] getGrac() {
        ...
    }
}

public class EecSiouph extends Duar {
    public Predhil getWaOd() {
        ...
    }
}

public class Gint {
    public List<String> getLosm() {
        ...
    }
}

public class Kalha extends Atha {
    public Kipras getIand() {
        ...
    }
}

public class Kipras {
    public List<String> getEght() {
        ...
    }

    public List<Dismer> getUnFigis() {
        ...
    }
}

public class NasGintcesm {
    public List<EecSiouph> getNiosus() {
        ...
    }

    public int getRiTi() {
        ...
    }
}

public class Ocaun extends NasGintcesm {
    public List<String> getEnur() {
        ...
    }
}

public class Predhil {
    public Vilpred getSobor() {
        ...
    }

    public Curiol getCil() {
        ...
    }
}

public class PriHise {
    public String getPaph() {
        ...
    }
}

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

    Ocaun cin

    ...and the following method:

    public void process(int item)

    ...write code to process the poTiruc of the first unFigi of the first upsir of the first niosu of cin.

    Solution

    for (EecSiouph niosu : cin.getNasGintcesm().getNiosusList()) {
        for (CleCossni upsir : niosu.getWaOd().getCil().getUpsirsList()) {
            for (Dismer unFigi : upsir.getKalha().getIand().getUnFigisList()) {
                process(unFigi.getPoTiruc());
            }
        }
    }

Related puzzles: