File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Serious brain fart right now Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serious brain fart right now" Watch "Serious brain fart right now" New topic

Serious brain fart right now

Mark Fabrizio

Joined: Mar 31, 2003
Posts: 7
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

Joined: Jul 22, 2000
Posts: 9044
Person has a Role of Salesman and/or Dealer?

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Mark Fabrizio

Joined: Mar 31, 2003
Posts: 7
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"

Joined: Sep 29, 2000
Posts: 8521
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.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Mark Fabrizio

Joined: Mar 31, 2003
Posts: 7
Thanks for your help,
I think I was trying to use inheritance for the wrong reasons.
I agree. Here's the link:
subject: Serious brain fart right now
Similar Threads
Overriden Methods
Anonymous inner class
Arraylist insights
When to use Abstract Class and when to use Interface?
Anonymous classes. . .