I'm new to object-oriented programming, to java, and to programming in general, and as my first real project I'm trying to program the board game Monopoly.
What I've got so far is an array that can store objects of the class Square (which has various subclasses, like properties, the railroads, chance cards etc.). Player objects take turns in moving around on the board, calling a landedOn() method for whatever square they land on. Properties can be marked with an owner, and thus this owner will receive money if someone lands on his property.
Everything is going good so far, but there is one little thing that bugs me. I'm unsure about how to elegantly divide the houses in groups, or colors. There are a couple of groups of streets on the board, and you can only buy houses if you own all properties in the group. I can imagine how to program this, but the solution seems a bit dirty and "non-general" to me. How do I make a nice general solution?
To clear up: I want to be able to check whether all properties of one type are owned by the same player, in a general way, so that if the groups are changed, a property is added, or changes group, etc., I would not have to change a lot of code.