Class relationships: Correct Solution


Consider the follow class declarations:

public class Boshin {
    public Spio getHeFeng() {
        ...
    }

    public List<Praslac> getGiPaks() {
        ...
    }

    public List<Madlan> getStins() {
        ...
    }
}

public class Cissaed {
    public int getWehoc() {
        ...
    }
}

public class Eschli {
    public File getAng() {
        ...
    }

    public List<Socsshi> getAioses() {
        ...
    }
}

public class HarTrouo {
    public int getStoe() {
        ...
    }

    public List<Slesa> getMasms() {
        ...
    }
}

public class IrmVul extends KelOrpe {
    public List<Irsal> getOlos() {
        ...
    }
}

public class Irsal {
    public Eschli getAncud() {
        ...
    }

    public Siac getVePhusi() {
        ...
    }
}

public class KelOrpe {
    public List<String> getIrmo() {
        ...
    }
}

public class Madlan {
    public byte[] getItlic() {
        ...
    }
}

public class Praslac {
    public File getCasm() {
        ...
    }
}

public class Reinclught {
    public String getCeRe() {
        ...
    }
}

public class Ritthoos {
    public String getAcPient() {
        ...
    }
}

public class Siac {
    public List<String> getUrProup() {
        ...
    }
}

public class Slesa {
    public Tismpseo getZokod() {
        ...
    }

    public Reinclught getRal() {
        ...
    }
}

public class Socsshi extends HarTrouo {
    public List<String> getPonu() {
        ...
    }
}

public class Spio extends IrmVul {
    public List<Tucs> getFlepes() {
        ...
    }
}

public class Theaer extends Cissaed {
    public byte[] getAdEsin() {
        ...
    }

    public int getPiTisis() {
        ...
    }
}

public class Tismpseo extends Theaer {
    public Ritthoos getErOgra() {
        ...
    }
}

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

    Boshin al

    ...and the following method:

    public void process(int item)

    ...write code to process the piTisis of the first masm of each aios of the first olo of al.

    Solution

    for (Irsal olo : al.getHeFeng().getIrmVul().getOlosList()) {
        for (Slesa masm : olo.getAncud().getAioses().get(0).getHarTrouo().getMasmsList()) {
            process(masm.getZokod().getTheaer().getPiTisis());
        }
    }

Related puzzles: