Hi. I haven't much experience constructing classes with parameters to be honest which is why I'm feeling a bit lost now. In my project I have these classes I'm currently working with that are mapped to 2 different HashMaps: HashMap #1 contains all the xStatement classes (for keywords) e.g. a StringStatement class which implements the Directive interface, and the second HashMap stores variable names and values for easier search and manipulation; it has the TPLVariable class with constructor for a variable name, which is extended by the TPLString with constructors for the respective values plus the superclass constructor (so the TPLString class constructor should have strings for the variable's name and value), and TPLInteger classes.
I start with a String from an ArrayList, which is broken into two Strings (parts). The first part of the String is the keyword that maps to HashMap 1 (parts)and tells the program which of the Statement classes it's supposed to call up. After the appropriate Statement class is triggered, the contents of parts is what gets processed in it. parts is tokenized and parsed and saved into the HashMap #2 as variable name and values, but I need some way to check whether the value being instantiated is a String or an int. Now in the StringStatement class, what's supposed to happen is that I need to instantiate a new TPLString type of TPLVariable, with its name and an empty string. Later on I need to be able to change the empty string to some assigned value. The same thing goes for the TPLInteger class. How should I write my constructor(s) for the various classes so it can do that? Need some hints as to what I should be doing with all these. Thanks for the help in advance!
"How do you define fool?"
"I don't attempt it. I wait for demonstrations. They inevitably surpass my imagination."
subject: Subclassing and creating a new instance of a variable and putting it into a HashMap