Skip to main content
1 of 2
Gerstmann
  • 207
  • 3
  • 8

As others have pointer out, you should generally prefer composition over inheritance(is-a vs. has-a):

public class Creature {
    private Inventory mInventory;

    public boolean hasInventory() {
        return mInventory != null;
    }

    public Inventory getInventory() {
        return mInventory;
    }

    public void setInventory(Inventory inventory) {
        mInventory = inventory;
    }
}

This makes a much more flexible architecture in cases where you might want to make an exception for some specific creature. Consider the famous mudcrab merchant in Morrowind for example.

Gerstmann
  • 207
  • 3
  • 8