kirennia
Part of the furniture
- Joined
- Dec 26, 2003
- Messages
- 3,857
Have come up with another problem of sorts; I know a way around it but with my program running as it is, it turns 2lines of code into 45 so I'd rather do things this way if I can just learn the syntax.
Can't really think of a simple way of explaining it so I might babble a bit. What I'm trying to do is call a method from a String. It's not an issue of inheritance or whatever, I mean for example, I have a method called 'JoeBloggs' and a method called 'JillBloggs'. If for example the user had a radiobutton to select one of those and on clicking OK, it'd run one of those methods. The normal way of doing it would be to say that if joebloggs is pressed, run this etc etc but I don't want that. I want the selected component(got it inputted as a String) to run the method called the same thing. So using the String JoeBloggs would attempt to call the JoeBloggs method.
Erm...to try and further clarify, I'll put some code here:
So I now have a String called 'getLevel1easy1' and I wish any existing method called that to run. You can see the problem I have when there are a few levels...and a few difficulties.
In fact, I've jsut noticed a better way of doing this would be with a dynamic 3dimensional(maybe 4 )ListArray but I'm still interested as to how I could do this for future reference and all
Are there any decent java type people who would be willing to add me on MSN for occasional questions?
Can't really think of a simple way of explaining it so I might babble a bit. What I'm trying to do is call a method from a String. It's not an issue of inheritance or whatever, I mean for example, I have a method called 'JoeBloggs' and a method called 'JillBloggs'. If for example the user had a radiobutton to select one of those and on clicking OK, it'd run one of those methods. The normal way of doing it would be to say that if joebloggs is pressed, run this etc etc but I don't want that. I want the selected component(got it inputted as a String) to run the method called the same thing. So using the String JoeBloggs would attempt to call the JoeBloggs method.
Erm...to try and further clarify, I'll put some code here:
Code:
String temp = inputStream.readLine();
//Insert calling code here
public String getLevel1easy1() {
return level1easy1;
}
public String getLevel2easy1() {
return level1easy1;
}
So I now have a String called 'getLevel1easy1' and I wish any existing method called that to run. You can see the problem I have when there are a few levels...and a few difficulties.
In fact, I've jsut noticed a better way of doing this would be with a dynamic 3dimensional(maybe 4 )ListArray but I'm still interested as to how I could do this for future reference and all
Are there any decent java type people who would be willing to add me on MSN for occasional questions?