3

I have static data which represents a Skin that has parts such as

  • head
  • body
  • right hand
  • left hand
  • right leg
  • left leg

and each of those parts have sides/faces:

  • top
  • bottom
  • left
  • right
  • back
  • front

Now I want to represent these in my code in such a way that I can relate them to each other such as

SkinPart.HEAD.TOP
SkinPart.HEAD.BOTTOM

and also from the sub part(top, bottom) i want to be able to access the data, whose top side is this?

Is this kind of relation possible to do in compile time(?)

My current implementation includes enums at it gets really messy..

I have bunch of maps that has parts as keys and side maps as values..

The compile time relation isn't really nessaccary.. I was just wondering how design wise I should do this without being bloated with maps of maps and without the need to write custom search functions in order to keep tracks whats whos

Is the only way to go to create a class and dynamically fill the lists and lose the ability to statically access the data eventhough the types are known and will never change(?)

4
  • By static do you mean static or do you mean final? Commented Apr 16, 2014 at 20:52
  • Neither, I mean data that is predefined and is accessible at code level, such as enums, like if i create enum Part {HEAD, BODY;} I can access those parts like Part.HEAD or Part.BODY Commented Apr 16, 2014 at 20:53
  • 2
    I might be a little confused as to what exactly you are looking for... does this answer your question? Commented Apr 16, 2014 at 20:56
  • I didn't know you could have enum inside enum.. That's brilliant! Thanks! Commented Apr 17, 2014 at 21:56

1 Answer 1

0

If I were you and if I had understood your question right, I would write a superclass with all the sides/faces with an access modifier of protected (only packages and subclasses). Then you can extend your Skin with the sides/faces

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.