Java enum pairs / "subenum" or what exactly?
- by vemalsar
I have an RPG-style Item class and I stored the type of the item in enum (itemType.sword). I want to store subtype too (itemSubtype.long), but I want to express the relation between two data type (sword can be long, short etc. but shield can't be long or short, only round, tower etc). I know this is wrong source code but similar what I want:
enum type
{
sword;
}
//not valid code!
enum swordSubtype extends type.sword
{
short,
long
}
Question: How can I define this connection between two data type (or more exactly: two value of the data types), what is the most simple and standard way?
Array-like data with all valid (itemType,itemSubtype) enum pairs or (itemType,itemSubtype[]) so more subtype for one type, it would be the best. OK but how can I construct this simplest way?
Special enum with "subenum" set or second level enum or anything else if it does exists
2 dimensional "canBePairs" array, itemType and itemSubtype dimensions with all type and subtype and boolean elements, "true" means itemType (first dimension) and itemSubtype (second dimension) are okay, "false" means not okay
Other better idea
Thank you very much!