This is not about BrainF*ck. Please refer to the last section for the "ultimate" question.
I am terribly sorry, if that has been asked before, but I just couldn't find a page where this has been asked before.
I basically have a java project set up, that let's you write BrainF*ck code and then execute it. For those who don't know, BrainF*ck is a very simple programming language that only uses one-character commands.
I have set it up to where all the implemented letters have individual classes that extend to a Token superclass.
public abstract class Token {
private final char token;
public Token(char c) {
this.token = c;
}
public final char getToken() {
return token;
}
public abstract void tokenCalled();
}
So as an example, for the Token '+' I would have the class set up like this.
public class PlusToken extends Token {
public PlusToken() {
super('+');
}
@Override
public void tokenCalled() {
//increment value by 1
}
}
This works all fabulously well.
Now for my project, I wanted the user to be able to create his own classes and put them in a pre-existent folder where my program will loop through the classes and include those Tokens into my projects. I have an arraylist set up that contains all the Tokens, so the only problem I'm having is: How do I read those classes, check if they are instances of Token and save those in my arraylist to use them?