• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Serious brain fart right now

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a Design issue here. I want to have an object Person (or an interface, depending) be a base class. I then want to allow another class, Dealer, to extend or implement Person. I also want a class called Salesman to extend or implement Person.
For some reason, I can't think of a way that would allow a Person to be both a Dealer and a Salesman at the same time.
Any comments/help on this would be greatly appreciated.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Person has a Role of Salesman and/or Dealer?
 
Mark Fabrizio
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes,
A Person can exist by itself. A Dealer inherits all Person methods as does a Salesman. A Person could be a Salesman and a Dealer at the same time. But it could also just be a Salesman, or just a Dealer.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a person "has a" role (or multiple roles) instead of "is a" salesman or whatever, then there is no problem.
The roles would not necessarily extend person, they would just define job behaviors.
 
Mark Fabrizio
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help,
I think I was trying to use inheritance for the wrong reasons.
 
reply
    Bookmark Topic Watch Topic
  • New Topic