Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   General Computer Support (http://www.velocityreviews.com/forums/f44-general-computer-support.html)
-   -   Problem in Java - Interface and passing methods as parameters (http://www.velocityreviews.com/forums/t742190-problem-in-java-interface-and-passing-methods-as-parameters.html)

Hoy2Coy 01-17-2011 07:31 PM

Problem in Java - Interface and passing methods as parameters
 
I was wondering how to put a method as a parameter in Java. I know there are other posts about this but I can't make sense of them (something to do with interface, right?). I'm relatively new to Java so I just know the basics. The reason I need to be able to do this is because I'm making an interactive story with each section being its own method. In pseudo-code I want it to be something like this:

public class Interactive_Story {

void Choose(Takes methods a and b as parameters){
if (user input=="a"){
Execute method a
}else{
if (user input=="b"){
Execute method b
}
}
}

void Start(){
Output beginning of story on the console.
Choose(Do_This,Do_That)
}

void main (String[] args){
Start()
}

}

I hope you see what I'm trying to get at. If you have any ideas or informative links please post them as soon as possible.

Thanks,
Hoy2Coy


All times are GMT. The time now is 05:01 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.