- Use a Collection to store the objects of classes derived from the same super class.
- Use foreach to process the elements of a Collection.
- Validate the data what you get from the user; throw Exception for invalid data, and handle the thrown Exceptions.
- The documentation should contain:
- the description of the exercise,
- the class diagram,
- the short description of each methods,
- and the testing (white box / black box)
Make a simplified monopoly game. Things to have:
* Money
init == 10000
* type/Strategies
* Greedy player: Buy everything possible when have enough money
* Careful player: Spend no more than half of the money each round
* Tactical player: Skip second buy chance
Contains the collection of player and fields
* property
* service
* lucky field
* property == 1000
* service ==
* lucky field ==
* build house == 4000
* step on property without house == -500
* step on property with house == -2000
* service field == -TBA
* lucky field == +TBA
Mandatory used.
For a more programmatic way of making a diagram. NOTE: use "skinparam classAttributeIconSize 0" in plantuml to change the symbol of visibility from geometric shape(triangle,square and circle) to the classic(#,-,+).
For version control and easy to traceback.
Simulate a simplified Capitaly(aka Monopoly) game. There are some players with different strategies, and a cyclical board with several fields. Players can move around the board, by moving forward with the amount they rolled with a dice.
A field can be a property, service, or lucky field. A property can be bought for 1000, and stepping on it the next time the player can build a house on it for 4000. If a player steps on a property field which is owned by somebody else, the player should pay to the owner 500, if there is no house on the field, or 2000, if there is a house on it. Stepping on a service field, the player should pay to the bank (the amount of money is a parameter of the field). Stepping on a lucky field, the player gets some money (the amount is defined as a parameter of the field).
Initially, every player has 10,000.
Greedy player: If he steps on an unowned property, or his own property without a house, he starts buying it, if he has enough money for it.
Careful player: he buys in a round only for at most half the amount of his money.
Tactical player: he skips each second chance when he could buy.
If a player has to pay, but he runs out of money because of this, he loses. In this case, his properties are lost, and become free to buy.
Read the parameters of the game from a text file. This file defines the number of fields, and then defines them. We know about all fields: the type. If a field is a service or lucky field, the cost of it is also defined. After the these parameters, the file tells the number of the players, and then enumerates the players with their names and strategies. In order to prepare the program for testing, make it possible to the program to read the roll dices from the file.
Print out which player won the game, and how rich he is (balance, owned properties).
4(Number of fields)
property
property
lucky field 2000
service 1000
3 (Number of player)
Bob greed
Bill careful
John tactical
3
4
5
7
10
3
2
1