Results 1 to 4 of 4
  1. #1
    java_fun2007 is offline Member
    Join Date
    Nov 2007
    Posts
    35
    Rep Power
    0

    Default inheritance and aggregation

    hi,
    I have a question about this relation

    http://img143.imageshack.us/img143/1...problemeq3.png

    Class A has aggregation relationship with Class B

    Class B has aggregation relationship with Class C

    Class B has Inheritance relationship with Class D

    Class D has aggregation with Class E

    Class C and Class E have almost the same attributes and methods, is that mean that Class E has extended the Inheritance too or should I write the attributes and methods again?? :confused:

    thanks

  2. #2
    java_fun2007 is offline Member
    Join Date
    Nov 2007
    Posts
    35
    Rep Power
    0

    Default

    Do I need an abstract class? :rolleyes:

  3. #3
    dmacvittie is offline Member
    Join Date
    Aug 2007
    Posts
    30
    Rep Power
    0

    Default

    Not an easy question to answer with the information you have provided. If all of C is in E or all of E is in C, then yes, making one a subclass of the other makes sense in most cases.

    Aggregations don't generally need any form of relationship - the relationship is defined by the fact that one holds a collection of the other.

    Hope that helps!

    Don.
    Don MacVittie F5 Networks - DevCentral

  4. #4
    java_fun2007 is offline Member
    Join Date
    Nov 2007
    Posts
    35
    Rep Power
    0

    Default

    yeah I guess I should add inheritance between those two classes too :)

    Thanks for you help!

    Dan

Similar Threads

  1. Delegation vs inheritance
    By javaplus in forum Advanced Java
    Replies: 1
    Last Post: 12-07-2007, 10:07 PM
  2. Inheritance
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-07-2007, 07:08 PM
  3. Multiple Inheritance
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-01-2007, 11:04 PM
  4. Inheritance in GUI
    By Marty in forum SWT / JFace
    Replies: 2
    Last Post: 05-11-2007, 01:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •