referring to object variables in array
in
Programming Questions
•
3 years ago
Hi, hello
I've been trying various ways to structure this, but I always end up stuck.
What I'm trying to make is a conjugational table for verbs where the user has to write in the conjugations and have feedback of whether it was correct.
My problem for now is grouping that mass of variables for the many conjugations of a verb (where of course I'd have tons of verbs later, of which it needs to pick a random one).
My first approach was making a verb class, but then the objects deriving from it would have to look like -
- Verbs verb1 = new Verb (conj1, conj2, 3, 4, 5, 6......30);
- Verbs verb2 = new Verb (conj1, conj2, 3, 4, 5, 6......30);
- .... verb117 ...verb129 ...
which I thought was impractical. Then I created the individual verbs as classes making their own object. I still don't think that's optimal.
>>What is annoying me most though, is that I can't figure out how to refer to
the variables (properties) of the objects to then check them against the user input. I also figure all the objects have to be in an array so that I can later tell it to pick one at random, display it and ask for its conjugations. (I'll use controlP5 text boxes for the user input).
The need for them to be in an array then makes it so that I'd have to refer to the picked verb as > verbList[randNum]
and I can't refer to it with > verb1.conjugation5 (for example)
Can you help me structure and express that to make it work ?
1

I don't blame you (see no offense here!), just wondering. Actually nothing wrong here, you took the right side of the problem, but that's more to learn.