Originally posted by Barry Brashear: Does anyone know how to go about designing a monopoly game for Java?
Try writing out the game and it's rules on a piece of paper (or just get the official manual). Then underline all the nouns and verbs on your piece of paper. The nouns are candidates for classes while the verbs are candidates for methods of those classes (of course, not all of them are relevant!).
Originally posted by Barry Brashear: Thanks. I guess that would include board, player, property, hotel, house, etc.
Among others, yes. And these are all classes. A "verb example": a player should have a method called move(...) to move from one section of the board to another.
Also, there could be a main class called Game, which holds the references to a Board instance, Player instances, a couple of Die (Dice) instances, etc. In that Game instance, you create a loop that keeps on looping giving each player on the board a turn to play. This loop is terminated whenever one of the players has won.
While the verb/noun approach provides a first approximation at an object model, I'd say that it'd be a mistake to take its results too literally. A good object model isn't necessarily the one that mimics the real world perfectly - it needs to make sense for the application code.
E.g., I don't see what methods house or hotel objects would have. They differ in the amount of rent due, but that's an attribute of the property. So I might make the number of houses/hotels fields of a property object they belong to.
And there might be other objects that have no corresponding physical object.
You might find this discussion about modeling a tennis match interesting. [ July 11, 2008: Message edited by: Ulf Dittmer ]
I wasn't selected to go to mars. This tiny ad got in ahead of me: