You will need composition and polymorphism.
Assuming a player can have more than one property, you will need a Property List. If the properties may differ in the attributes that they have, you can apply Polymorphism and Inheritance. You will probably see only Inheritance below, but you will need Polymorphism when you get various properties and manipulate them.
Mostly:
public static void main(String args[]){ Player player1 = new Player(); BlackProperty blackProperty = new BlackProperty(); BlueProperty blueProperty = new BlueProperty(); player1.addProperty(blackProperty); player1.addProperty(blueProperty); }
All your domain classes:
public class Player{ private List<Properties> propertyList; // getters and setters public void addProperty(Properties properties){ if(this.propertyList == null){ this.propertyList = new ArrayList<Properties>(); } this.propertyList.add(properties); } } public class Properties{ private int noOfFloor; // getters and setters } public class BlackProperty extend Properties{ private String noOfGate; // getters and setters } public class BlueProperty extend Properties{ private String noOfLawn; // getters and setters }
source share