public class Item { public boolean canRotate() { return false; }}public class Building extends Item { public boolean canRotate() { return true; }}(test code)ArrayList<Item> items = new ArrayList<Item>();items.add(new Item());items.add(new Building());for(Item item : items) { if(item.canRotate()) System.out.println("This item can rotate."); else System.out.println("This item cannot rotate.");}
In this situation (and it may not fit what you are trying to model), Building *is* everything that an Item is, and more. AbleToBePlacedOnAGrid was just an example class, you don't really need it. If you wanted to inherit from a general superclass for your game model, then you should call it something like GameObject or Entity or GridObject (Building extends GridObject, Item extends GridObject).