Calling a function from a string

edited January 2016 in How To...

Hello! I have been working on a program and have run into a problem: I want to make a class where you can name the "Program" that this class is defining, and then run that function. Basically, call a function like you do in a thread, but I want to be able to display things. here is the class:

class App {
  String Name;
  int ID;
  App(String n,int i){
    Name = n;
    ID = i;
  }
  void Run(){
    //This is what I need! :0
  }
}  

//and this is how I want to be able to use it:  
App Test = new App("Test",0);

void Test(){
  background(255);
  //Do some other stuff
}
//run the function like this:
void draw(){
  Test.Run();
}  

so what I want to know is, how do I do it? :-/

Tagged:

Answers

Sign In or Register to comment.