I am making a Roguelike game in java, and I want every creature to have bodyparts (as in Dwarf fortress). I was just wondering what the best way to implement this might be.
Like most things in Java you could start modeling it all in objects. Take all the appropriate nouns from your requirements (creature and bodypart) and figure out their relationships (a creature has several bodyparts).
public class Creature {
private ArrayList<BodyPart> bodyParts;
// could be array instead
}
public class BodyPart {
public int health;
}
As to how to use it in your rougelike game it depends on how you want to write your actual game.
Edit:
Here is a gist to help you get started: https://gist.github.com/spoike/5023039