Problem in Java - Interface and passing methods as parameters

Discussion in 'General Computer Support' started by Hoy2Coy, Jan 17, 2011.

  1. Hoy2Coy

    Hoy2Coy

    Joined:
    Jan 17, 2011
    Messages:
    1
    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
    Hoy2Coy, Jan 17, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ambrish Verma
    Replies:
    0
    Views:
    445
    Ambrish Verma
    Apr 4, 2007
  2. Ambrish Verma
    Replies:
    0
    Views:
    429
    Ambrish Verma
    Apr 11, 2007
  3. Ambrish Verma
    Replies:
    0
    Views:
    389
    Ambrish Verma
    Apr 11, 2007
  4. vvmuneer

    Problem in Arabic URL parameters

    vvmuneer, Aug 1, 2007, in forum: Software
    Replies:
    0
    Views:
    878
    vvmuneer
    Aug 1, 2007
  5. boyabhi123

    Calling Java methods in C

    boyabhi123, Aug 2, 2007, in forum: Software
    Replies:
    0
    Views:
    1,051
    boyabhi123
    Aug 2, 2007
Loading...

Share This Page