How should I create a mutable, varied jtree with arbitrary/generic category nodes?

Posted by Pureferret on Programmers See other posts from Programmers or by Pureferret
Published on 2012-09-03T15:38:37Z Indexed on 2012/09/03 15:50 UTC
Read the original article Hit count: 230

Filed under:
|
|

Please note: I don't want coding help here, I'm on Programmers for a reason. I want to improve my program planning/writing skills not (just) my understanding of Java.

I'm trying to figure out how to make a tree which has an arbitrary category system, based on the skills listed for this LARP game here. My previous attempt had a bool for whether a skill was also a category. Trying to code around that was messy. Drawing out my tree I noticed that only my 'leaves' were skills and I'd labeled the others as categories.

enter image description here

Explanation of tree: The Tree is 'born' with a set of hard coded highest level categories (Weapons, Physical and Mental, Medical etc.). Fro mthis the user needs to be able to add a skill. Ultimately they want to add 'One-handed Sword Specialisation' for instance. To do so you'd ideally click 'add' with Weapons selected and then select One-handed from a combobox, then click add again and enter a name in a text field. Then click add again to add a 'level' or 'tier' first proficiency, then specialisation.

Of course if you want to buy a different skill it's completely different, which is what I'm having trouble getting my head around let alone programming in.

What is a good system for describing this sort of tree in code? All the other JTree examples I've seen have some predictable pattern, and I don't want to have to code this all in 'literals'. Should I be using abstract classes? Interfaces?

How can I make this sort of cluster of objects extensible when I add in other skills not listed above that behave differently?

If there is not a good system to use, if there a good process for working out how to do this sort of thing?

© Programmers or respective owner

Related posts about planning

Related posts about trees