Class relationships: Correct Solution


Consider the follow class declarations:

public class Aamp {
    public byte[] getLoPsunt() {
        ...
    }

    public Psaph getPhe() {
        ...
    }
}

public class Ciosh extends Ioeng {
    public Tretsa getVuEs() {
        ...
    }

    public List<Gacont> getPses() {
        ...
    }
}

public class Clarclass extends Feve {
    public File getOrcir() {
        ...
    }
}

public class DacCalted {
    public File getMeast() {
        ...
    }
}

public class Feve {
    public List<Moghtu> getReVoses() {
        ...
    }

    public Padnost getTisel() {
        ...
    }
}

public class Gacont {
    public File getPri() {
        ...
    }
}

public class Ioeng {
    public int getTia() {
        ...
    }

    public List<Aamp> getSpes() {
        ...
    }
}

public class Moghtu {
    public int getFoPra() {
        ...
    }
}

public class Padnost {
    public String getEck() {
        ...
    }

    public List<Ciosh> getIlsons() {
        ...
    }
}

public class Psaph {
    public String getIsProan() {
        ...
    }

    public Stisen getIdEpre() {
        ...
    }

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

public class Stisen {
    public int getLilhe() {
        ...
    }
}

public class Tretsa extends DacCalted {
    public byte[] getCreha() {
        ...
    }
}
  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:

    Clarclass u

    ...and the following method:

    public void process(byte[] item)

    ...write code to process the doass of the first spe of the first ilson of u.

    Solution

    for (Ciosh ilson : u.getFeve().getTisel().getIlsonsList()) {
        for (Aamp spe : ilson.getIoeng().getSpesList()) {
            process(spe.getPhe().getDoass());
        }
    }

Related puzzles: