Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > Problem in Java - Interface and passing methods as parameters

Reply
Thread Tools

Problem in Java - Interface and passing methods as parameters

 
 
Hoy2Coy Hoy2Coy is offline
Junior Member
Join Date: Jan 2011
Posts: 1
 
      01-17-2011
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static methods and passing functions as parameters. JBB123 Java 1 12-08-2011 09:13 AM
Methods for passing parameters while moving in various Java ServerPages (JSP) Weasley Java 2 12-05-2009 03:18 PM
Passing parameters to an executable vs. passing them to a server Ramon F Herrera C++ 8 09-13-2009 02:48 AM
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
On Java's Interface (the meaning of interface in computer programing) Xah Lee Java 15 03-23-2007 10:30 PM



Advertisments