0

What would be a good way to implement a race system similar to Roguelike in Java.

I have been thinking about making each creature a subclass of it's race but I'm not sure this is a good way to do things.

Mike Wills
  • 20,959
  • 28
  • 93
  • 149
  • 3
    Please read the FAQ at http://stackoverflow.com/faq your question is not a good fit for stack overflow. Maybe one of the sister sites but not this one. – Kevin D Feb 24 '13 at 12:17
  • possible duplicate of [How could I implement body parts in a Java roguelike game](http://stackoverflow.com/questions/15049510/how-could-i-implement-body-parts-in-a-java-roguelike-game) – Andrew Thompson Feb 24 '13 at 12:21

1 Answers1

0

You certainly don't want a subclass relationship. I would use composition rather than inheritance.

In particular, I would make a class Race

public class Race {

    public String name;

    public Race(String name) {
        this.name = name;
    }

}

and ensure that each creature has a Race field.

Chris Taylor
  • 46,912
  • 15
  • 110
  • 154