Monopoly in C++


Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


You are asked to program a game called Monopoly in C++. This game is played by two players (you and computer in this assignment). The game and its rules are described as the follows.

• Account Setup:

Each player must establish an account with a positive balance, starting with a deposit of 5000 units. This means that you have to set up a data base (a file) which records the players’ information, for example, name, gender and account balance etc. and the program is supposed to be able to track the balance changes as the game is going.

• Game Board:

This game is played on a game board as shown in Fig. 1, consisting of 38 squares. Each square, except for the four corner squares (the "GO" square, two "CASSINO" squares, and the "JAIL" square), has a price tag for ownership, with prices randomly generated within the range of 10 to 300.

All players begin at the "GO" square, and each time a player passes the "GO" square, their account balance is increased by 200 units.

• Gameplay Mechanics:

You and the computer take turnsto roll a dice. The outcome of each rolling (a random number withinthe range of 1 to 6) decides how many squares you/computer can advance in a clockwise direction on the board.After you have landed on a square:

- if this square is unoccupied (so this means each square except “GO” and “JAIL” has an ownership attribute): you can decide whether or not you should buy it;
- if this square is occupied by you (you’ve already bought it), then nothing needs to be done;
- if this square is occupied by your opponent and the adjacent squares are unoccupied or occupied by you: you will be fined by 10% of the square price;
- if this square and one of its adjacent squares are both occupied by your opponent (which means you opponent has purchased 2 consecutives squares): you will be fined by 20% of the square price;

- The fine is topped at 20% of the square price even if more than 2 consecutive squares havebeen occupied by your opponent.

• Special Squares:

Landing on the "JAIL" square requires the player to wait for one round before moving again;

Landing on a "CASSINO" square prompts the player to decide whether to gamble. If the player declines, nothing happens. If the player accepts, they must place a bet, and the casino rolls a dice.

The player must predict if the outcome will be greater than 3 or not. A correct prediction results in a reward of twice the bet, while an incorrect prediction results in the loss of the bet;

• Game End Conditions:

The game ends under three scenarios:

-Aplayer declares bankruptcy (balance is less than or equal to 0); 

- Aplayer's account balance exceeds 15,000 units;

- The player chooses to quit the game.

Fig. 1 Game Board

Hint:
1. The computer's logic can be straightforward. For example, it could continuously purchase squares until it runs out of funds. Additionally, when landing on a "CASSINO" square, the computer could gamble a fixed amount, such as 100 points, each time. Alternatively, the computer 's actions could be determined by pre-defined probabilities to introduce variability in its behavior.
2. Employ the concept of Object-Oriented Design (OOD) to structure your game development. This involves utilizing distinct classes to encapsulate various aspects of the game. For instance, a Player class to manage player attributes and behaviors; a Map class to represent the game board and its properties, etc.

发表评论

电子邮件地址不会被公开。 必填项已用*标注