• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serious brain fart right now

 
Mark Fabrizio
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Person has a Role of Salesman and/or Dealer?
 
Mark Fabrizio
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help,
I think I was trying to use inheritance for the wrong reasons.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic