Jump to content
Sign in to follow this  
flareback

Java Program

Recommended Posts

So I'm working on a program and I'm not sure how I want to have it designed.

 

I have two classes a Person class and a Business class. I want to track those are donating to a cause. So a person can be a donor, but they may not be. And a Business can be a donor but they may not be. It would make sense for donor to extend Person and Business but you can't extend multiple classes.

 

So should I have Person and Business extend donor? But not all people are donors and I usually think of classes that extend as being an "is-a" relationship (Animal class and a Dog class that extends Animal, a Dog is an Animal but not all animals are dogs). So to me this doesn't seem to be ideal.

 

Any thoughts?

Share this post


Link to post
Share on other sites

I don't have a clue about java but it seems to me you could do it this way:

Have a "entity" class(person and business) and as an extension of that have business, person, business-donor and person-donor. or just business and person and person and then extend those further. Not ideal but it could maybe work... as i say i am clueless on java.

Hope that sparks an idea.

Share this post


Link to post
Share on other sites

I don't have a clue about java but it seems to me you could do it this way:

Have a "entity" class(person and business) and as an extension of that have business, person, business-donor and person-donor. or just business and person and person and then extend those further. Not ideal but it could maybe work... as i say i am clueless on java.

Hope that sparks an idea.

 

I thought about having a business-donor and a person-donor class but the donor parts are going to be very similar. Seems like I would be re-writing a lot of code. Plus if I changed anything I'd have to change it in both places.

Share this post


Link to post
Share on other sites

It's been awhile since I did Java, but I think....

 

Have both People and Business extends Donor. Then use a flag variable to state whether or not they are a donor. Then just do whatever it is you need to do that is shared within the Donor class. Then everything that's different in People and Business.

Share this post


Link to post
Share on other sites

Dude can you reword that in a simpler form ? i do a good but of java think i might have some help here , i might hit you with a question afterwords

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...