Originally I used a java Hashtable. The key is a String for the parameter name, and the type of the elements are Objects (for use with wrapper classes and Strings largely). However, to account for the multiple constructors, I also need to record the priority of each parameter.
Let's say that I had the following constructors:
public Foobar(int x, int y, String name, double gravity){
this.x=x;
this.y=y;
this.name=name;
this.gravity=gravity;
}
public Foobar(int x, int y, String name){
this.x=x;
this.y=y;
this.name=name;
this.gravity=9.8;
}
I'd need to mark the x and y variables for use in the level editor, mark name as a required variable, and mark gravity as an optional variable.
I could go with 2 Hashtables each having the same exact keys, but I feel as if there must be a better way to approach this - another data structure perhaps? Any advice?