Recent Question/Assignment
The Monopoly Game
You are to produce a design for a simple monopoly game. If you are not familiar with the game of monopoly can find plenty of overviews online and you will probably get a basic understanding of the game. Remember that we will only use a subset of the game in the assignment, and part of the problem when designing can actually be to keep a limited scope and not do too much (i.e. make an overly complicated design for some imagined future case). Try to limit your design to the task as described below and do not think about future features that could be nice to have.
The Board
The board will consist of a number of tiles. Tiles can be of different types as described below, and different rules apply when a player stops on or passes over a tile. The tiles are arranged in a circular way. That is, players move from one tile to the next forward (or backward), and when reaching the last tile they start over at the first tile.
The tile types are:
Start tile: There is only one start tile. This is the tile where each player starts. When passing over the start tile a player should get 200 additional credits. Not that this does not apply the first time, i.e at the game start.
Free tile: Nothing happens on a free tile.
Property Tile: Property tiles have a street name and a cost. The following rules apply to when a player stops at a property tile. If it is not owned by a player, it can be bought by the player at the start of the next round (i.e. you buy properties before moving) if the player has enough funds. If another player owns the property you pay rent to that player with the amount of 300 credits.
The Dice
A player moves over the board by rolling two six-sided dice. The player moves the number of tiles equal to the sum of the dice values. If the dice values show the same values, the player will first move the number of steps shown, and then roll both dice again and move. This continues as long as the player dice show the same values. Note that if the player ends up on a free property tile the player can buy this property before rolling the dice again. If the player ends up on another players property rent must be payed before moving on.
Starting the Game
Each player enters their names and then gets 1000 credits. The players start at the Start Tile. The game begins when the last player has been added and then no further players can join.
Playing the Game
Starting with the first player, the player can either buy a property (if currently stopped on a free property tile) and finally roll the dice and move. Movement is always the last thing a player does and it is then the next players turn.
Ending the Game
The game ends after 10 rounds or when one player has become bankrupt (i.e. has zero or less credits). The winner of the game is the player with the most credits.
The User Interface
The user interface should be a simple console interface. The game board should be visualized with the tiles and where the players are positioned. All game actions should be reported (i.e. how much a player moves, if credits are added or removed from a player, if a property is bought or if the player pays rent, etc.)
The user interface should be encapsulated in it's own class and any input or output should be handled in this class. I.e. no system.out.print or system.in.read in any other part of the game.
Computer Player
In a future version it is expected that there will be a computer player. The design should be prepared for this upcoming feature.
Class diagram
Create a class diagram that shows the structure of the classes with the appropriate relations. The goal is to end up at a design level class diagram, but it is a good idea to create an analysis level diagram first. Feel free to add this analysis level diagram to your submission. Classes should of course be named, have relevant attributes (fields) and operations (methods). You should use relations between the classes such as generalization/specialization (inheritance), realziation, association or dependency, if appropriate and needed.
Object and Sequence diagram
To test your design you can try to see how it would work (i.e. how should the objects communicate to perform the task at hand) in particular situation. We call such a situation a scenario. Below is one scenario and you should create one object diagram and one sequence diagram for it using your classes.
The object diagram should show what objects and their links before the steps of the scenario is executed (the initial state). I.e. what does the system look like at this particular moment in time.
The sequence diagram show how the objects are used to perform the steps of the scenario, typically by using the objects from the object diagram. However new objects can also be introduced as the sequence diagram shows the dynamic execution of the system and objects can for example be created.
Considering the user interface it is not a central part of the current scenario. If you think there are messages that need to be sent to/from the user interface, an object of this type is likely needed. However, this is very much up to how you have designed your game.
Note that to be able to send a message between two objects there need to be some relation between them in the class diagram (association or dependency). If you find that your structure (class diagram) is lacking when modeling the scenarios, you should of course try to improve the structure. Feel free to add more scenarios that cover other situations.
Player moves scenario
Initial State
The player named -Boris- is currently at a property with street name -Downing Street-. Downing Street is the tile before the Start tile (i.e. it is the last tile on the board). After the start tile comes another property tile (-Seven Sisters Road-), after that we have another property tile (-Abbey Road-). The dice currently have the face value 6 and 2.
Steps
It is now Boris turn and he is offered the dice.
Boris rolls the dice and gets the values 1 and 2.
Boris moves from Downing Street, to the Start tile.
Boris moves from the start tile to Seven Sisters Road. As Boris has moved over the start tile, he receives 200 credits.
Boris moves from Seven Sisters Road to to -Abbey Road-. Boris stops at this tile. As the tile is free Boris is offered to buy this property at the start of his next round.
Model deliverables In the Assignment
You should create one class diagram, one object diagram and one sequence diagram as per the instructions above. The formats for these should be common image formats like png or jpeg (or you can use mermaid markdown). Use the intended.md, in this file you should present your images and possibly notes that is needed to be able to interpret them correctly using markdown. You should reasonably follow standard UML notation in the diagrams. When done you issue a merge request to the release branch.
________________________________-
I need help with the last part.
Player moves scenario
Initial State
The player named -Boris- is currently at a property with street name -Downing Street-. Downing Street is the tile before the Start tile (i.e. it is the last tile on the board). After the start tile comes another property tile (-Seven Sisters Road-), after that we have another property tile (-Abbey Road-). The dice currently have the face value 6 and 2.
Steps
It is now Boris turn and he is offered the dice.
Boris rolls the dice and gets the values 1 and 2.
Boris moves from Downing Street, to the Start tile.
Boris moves from the start tile to Seven Sisters Road. As Boris has moved over the start tile, he receives 200 credits.
Boris moves from Seven Sisters Road to to -Abbey Road-. Boris stops at this tile. As the tile is free Boris is offered to buy this property at the start of his next round.
Model deliverables In the Assignment
You should create one class diagram, one object diagram and one sequence diagram as per the instructions above. The formats for these should be common image formats like png or jpeg (or you can use mermaid markdown). Use the intended.md, in this file you should present your images and possibly notes that is needed to be able to interpret them correctly using markdown. You should reasonably follow standard UML notation in the diagrams. When done you issue a merge request to the release branch.