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

    Default Simple Inheritance issue...


    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
    Rep Power


    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
    Rep Power


    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
    Blog Entries
    Rep Power


    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 11:41 PM.

Similar Threads

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