Multiple object parameters? jbuilder2005
1 posts in topic
Flat View  Flat View

Posted By:   Brian_Menard
Posted On:   Wednesday, May 3, 2006 10:42 AM

Hey everyone I need some help...

I wrote a method called Cure1(Pacifist target), but it needs to be able to take one of many types of objects (Fighter, Scholar, Chef, Detective, Sage, Gambler) from classes that I created as parameters also.

Any thoughts?

Please keep in mind that in Cure1() I use methods from the objects that I mentioned, so the String and Objects classes don't seem to work as a medium to referncing them...



Im still *fairly* new to java, so please keep any explainations simple ^.^ Thanks in advance!

Re: Multiple object parameters? jbuilder2005

Posted By:   WarnerJan_Veldhuis  
Posted On:   Thursday, May 4, 2006 02:49 AM

Sounds like an RPG.... Make your Pacifist, Fighter, Scholar etc all share an interface called Curable. That interface would look like this:

public interface Curable {
void cure();

You can now have a method cure() that operates on anything that's "Curable"

public void cure( Curable target) {

That's where interfaces are for.... :)
About | Sitemap | Contact