Results 1 to 4 of 4
  1. #1
    AWE
    AWE is offline Member
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Default Simple Inheritance issue...

    Hello,

    I’m in a bit of a pickle !

    I have an abstract Event object with a number of obvious instance variables like name, description, start, end, creator etc.. This class also has a participant list under the form of a List<User>. So far so good. I have also made a FancyDressParty subclass of Event. In the context of a fancy party I’d like to add some context to each participant such as the Costumes they are wearing however I can’t see a way to do this elegantly without ending up with duplicate User lists (the List<User> inherited from Event and the FancyDressParty’s Map<User, Costume>).

    Any ideas?

    Many Thanks,

  2. #2
    ChazZeromus is offline Member
    Join Date
    Sep 2008
    Posts
    13
    Rep Power
    0

    Default

    Have you tried specifically designated which level of inheritance using "super"? So let me get this straight, you try to add some context to each user element inside ur abstract class's list but end up duplicate user lists? Meaning that List<User> information is wrongfully aligned with FancyDressParty's Map<User, Costume>?

  3. #3
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    What would be best is to create a subclass of "User" for each subclass of "Event".

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Would the Decorator design pattern used on the User be applicable here?

    Per Wikipedia, the decorator pattern is a design pattern that allows new/additional behaviour to be added to an existing class dynamically.
    Last edited by Fubarable; 07-27-2009 at 10:41 PM.

Similar Threads

  1. Inheritance example
    By kris4u4ever in forum New To Java
    Replies: 3
    Last Post: 03-21-2009, 02:53 PM
  2. inheritance
    By itaipee in forum New To Java
    Replies: 6
    Last Post: 01-20-2009, 08:18 PM
  3. inheritance basic.
    By newmember in forum New To Java
    Replies: 1
    Last Post: 08-02-2008, 09:35 PM
  4. Inheritance
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-07-2007, 06:08 PM
  5. Inheritance in GUI
    By Marty in forum SWT / JFace
    Replies: 2
    Last Post: 05-11-2007, 12: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
  •