Class relationships: Correct Solution


Consider the follow class declarations:

public class Adnua extends Braskial {
    public Erasm getPras() {
        ...
    }

    public Jiss getLiEcs() {
        ...
    }
}

public class Braskial {
    public String getChoar() {
        ...
    }

    public Chast getPelme() {
        ...
    }
}

public class Broso {
    public int getDed() {
        ...
    }
}

public class Canpad extends Giss {
    public byte[] getJic() {
        ...
    }
}

public class Casspan {
    public String getPihon() {
        ...
    }
}

public class Chast {
    public int getMedta() {
        ...
    }
}

public class Ciac {
    public String getScisa() {
        ...
    }
}

public class Cluh {
    public Preais getHeqal() {
        ...
    }

    public Ciac getJeck() {
        ...
    }
}

public class CouCino extends Adnua {
    public List<Broso> getPoPhlirs() {
        ...
    }
}

public class Darsu extends Preal {
    public Canpad getDoot() {
        ...
    }
}

public class Ediu {
    public String getPedon() {
        ...
    }
}

public class Erasm {
    public byte[] getSedal() {
        ...
    }
}

public class Giss {
    public List<CouCino> getEmtas() {
        ...
    }

    public String getBupla() {
        ...
    }
}

public class Jiss {
    public String getIac() {
        ...
    }

    public List<Pimim> getEdHazis() {
        ...
    }
}

public class Pimim {
    public int getReCavor() {
        ...
    }

    public String getNilad() {
        ...
    }
}

public class Preais {
    public List<Redvi> getPiEcs() {
        ...
    }

    public List<Casspan> getPlases() {
        ...
    }
}

public class Preal {
    public byte[] getTepes() {
        ...
    }
}

public class Redvi extends Darsu {
    public List<Ediu> getBres() {
        ...
    }
}
  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:

    Cluh ou

    ...and the following method:

    public void process(String item)

    ...write code to process the nilad of each edHazi of the first emta of the first piEc of ou.

    Solution

    for (Redvi piEc : ou.getHeqal().getPiEcsList()) {
        for (CouCino emta : piEc.getDarsu().getDoot().getGiss().getEmtasList()) {
            process(emta.getAdnua().getLiEcs().getEdHazis().get(0).getNilad());
        }
    }

Related puzzles: