Project
Purpose. Build a turn‑based Monopoly/Matador in plain Java using solid OOP and a clear analysis. This sheet is the blueprint: goals, scope, glossary, patterns, diagrams, and a week‑by‑week checklist.
- Practice object‑oriented analysis → from glossary & use cases to classes & responsibilities.
- Apply State, Command, Strategy, Observer, Factory, and Value Objects.
- Deliver a walking skeleton first; add rules iteratively with tests.
- Turn order with two dice; movement by sum; three doubles in a row → Jail.
- GO/START salary on pass/land (edition‑dependent amount).
- Landing on unowned property → choose Buy else Auction.
- Landing on owned property → pay Rent (double if you own full color group; not if mortgaged).
- Jail: sent by “Go to Jail” or 3 doubles; exit via doubles, fee, or Get Out of Jail Free.
- Mortgages: get cash; cannot collect rent; unmortgage = value + interest.
- No Free Parking jackpot (official rules only).
- Out of scope until Week 2: Houses/Hotels, build evenly, building shortages, bankruptcy transfers.
Decide early which edition numbers to use (EN vs DK amounts). Keep them behind a
RuleSet/policies, not hard‑coded.
| English | Dansk (Matador) | Short note |
|---|---|---|
| GO | START | Collect salary when passing/landing |
| Bank / Banker | Banken / Bankør | Holds money, deeds, buildings, runs auctions |
| Token | Brik | Player piece |
| Dice | Terninger | Two dice; 3 doubles → Jail |
| Property / Title Deed | Grund / Skøde | Ownable; rent charged to others |
| Color‑group | Farvegruppe | Own all → double base rent; enables building |
| Rent | Leje | Paid on landing, unless mortgaged |
| Auction | Auktion | If not bought when first landed |
| Houses / Hotels | Huse / Hoteller | Increase rent; build evenly (Week 2) |
| Chance / Community Chest | Prøv lykken | Card deck(s) with instructions |
| Jail | Fængsel | In Jail vs Just Visiting |
| Get Out of Jail Free | Løsladelseskort | Keep or sell; use to exit Jail |
| Free Parking | Parkering | Resting space; no payout |
| Income Tax | Indkomstskat | Edition rules vary |
| Mortgage | Pantsætning | Cash now; interest on unmortgage |
| Bankruptcy | Fallit | Transfer assets; leave the game |
| Short Game | Hurtigt spil | Variant policies/end conditions |
- Game (aggregate root): holds players, board, bank, decks, current turn/state.
- Player: token, cash, Portfolio (deeds, houses/hotel counts, mortgages), state (Active/InJail/Bankrupt).
- Bank: money source/sink; sells deeds/buildings; manages mortgages & auctions.
- Board: ordered list of Spaces (Go, Property, Utility, Railroad, Tax, Chance, Community, Jail, Free Parking, Go To Jail). Tracks wrap‑around, passing GO.
- TitleDeed (value object for rent table, buy price, mortgage value, color group).
- Deck & Card: draw, resolve effects, discard/return.
- DiceResult (value object), Position (value object), Money (value object).
State pattern → Turn flow & player state
- States: StartTurn → Roll → Move → ResolveSpace → PostActions → EndTurn → NextPlayer
- Player states: Active / InJail / Bankrupt
Command pattern → Atomic actions
RollDice,MoveToken,BuyProperty,PayRent,DrawCard,Auction,Mortgage,BuildHouse,EndTurn…
Strategy pattern → Rule variants as policies
SalaryPolicy,RentPolicy,TaxPolicy,JailExitPolicy,AuctionPolicy,BuildPolicy
Observer pattern → UI/log reacts to domain events
- Events:
PassedGo,LandedOn,RentCharged,BoughtProperty,WentToJail,DrewCard,BuiltHouse,Bankruptcy…
- Events:
Factory → Board & cards from data files
BoardFactory,CardFactory
Repository/Serialization → Save/Load game state (JSON or simple text)
@startuml
hide empty description
[*] --> StartTurn
StartTurn --> Roll : RollDice
Roll --> Move : dice sum
Move --> ResolveSpace : landed space known
ResolveSpace --> PostActions
PostActions -right-> EndTurn : player finishes
EndTurn -right-> NextPlayer
NextPlayer --> StartTurn
state PostActions {
[*] --> Decide
Decide --> Buy
Decide --> Auction
Decide --> PayRent
Decide --> Build
Decide --> Mortgage
Decide --> DrawCard
Buy --> [*]
Auction --> [*]
PayRent --> [*]
Build --> [*]
Mortgage --> [*]
DrawCard --> [*]
}
Roll --> Jail : third double
ResolveSpace -left-> Jail : Go to Jail
Jail -left-> StartTurn : exit via doubles/fee/card
@enduml
@startuml
hide stereotypes
skinparam packageStyle rectangle
package "Domain" as DomainPkg {
class Game
class Board
class Bank
class Decks
class TurnState
class Player
class Portfolio
class Space
class TitleDeed
}
package "Policies (Strategy)" as PoliciesPkg {
interface SalaryPolicy
interface RentPolicy
interface TaxPolicy
interface JailExitPolicy
interface AuctionPolicy
interface BuildPolicy
}
package "Actions (Command)" as ActionsPkg {
class RollDice
class MoveToken
class BuyProperty
class PayRent
class DrawCard
class Auction
class Mortgage
class BuildHouse
class EndTurn
}
Game --> Board
Game --> Bank
Game --> Decks
Game --> TurnState
Player --> Portfolio
Board --> Space
Space --> TitleDeed
' Layer relations
ActionsPkg ..> DomainPkg : mutates
PoliciesPkg ..> ActionsPkg : used by
TurnState ..> ActionsPkg : triggers
@enduml
✅ Glossary (EN↔DK) agreed and frozen for v1.
✅ Use‑cases: Buy, Pay Rent, Draw Card, Go To Jail, Auction, End Turn.
✅ Class & responsibility map (CRC cards / diagram) for Game, Player, Bank, Board, Space, TitleDeed, Deck, Card, Dice.
✅ Turn state machine (as above) + event list.
✅ Strategy interfaces chosen: Salary, Rent, Tax, JailExit, Auction.
✅ Walking skeleton runs: roll → move → pass GO salary → land → (buy or pay rent) → end turn (2–3 players, terminal UI).
✅ Data files for board & cards + BoardFactory/CardFactory stubs.
✅ Basic tests:
- Dice movement wraps board
- Passing GO pays salary per
SalaryPolicy - Rent on unimproved property; no rent when mortgaged
🔹 Houses/Hotels + build evenly rule via
BuildPolicy.🔹 Building shortages (limit of houses/hotels), auctions if needed.
🔹 Mortgages & unmortgage interest; rent blocked when mortgaged.
🔹 Jail exit options complete (doubles/fee/card turns counter).
🔹 Bankruptcy: transfer assets, remove player, optional auction of deeds.
🔹 Short‑game variant: swap policies to show polymorphism.
🔹 Observer log: print domain events to terminal (for debugging & grading).
🔹 Save/Load: serialize game state; reload and resume.
🔹 Scenario tests (happy path + edge cases):
- Completing a color group doubles base rent
- Third double sends to Jail
- Go To Jail does not pay salary on that move
- Build evenly enforcement
- Game: owns turn loop, current player, applies commands, emits events.
- Player: makes decisions; holds cash & portfolio; tracks jail/bankrupt state.
- Bank: sells deeds & buildings; handles mortgages; receives/pays money.
- Board: given a position and dice result → next position; exposes space by index.
- Space: knows how it resolves (rent/tax/draw/go to jail/visit/etc.).
- TitleDeed: immutable data (buy price, rent table, mortgage value, color group).
- Deck/Card: draw, execute effect, return as rules require.
- Policies: calculate salary, rent, taxes; decide jail exit; manage builds & shortages.
- Commands: encapsulated game actions; validate preconditions; produce events.
- Observer(s): terminal UI & log subscribers.
- Unit: value objects (Money, DiceResult, Position), policy calculations, commands.
- State/Workflow: turn transitions (incl. Jail), auction flow, mortgage lifecycle.
- Property‑based: random dice ensure board wrap & GO salary invariants.
- Scenario: scripted turns to assert event sequences.
- Bot player with simple heuristics (buy if cash ≥ X; build when group complete; mortgage least‑valuable first).
- Replay log: rebuild game from events for debugging.
- Configurable boards: theme swap (street names/colors) via data files only.
Hand‑in for Week 1: one‑page analysis (this sheet), diagrams, and a running skeleton that prints a short log of 3–5 turns with two players. Hand‑in for Week 2: rules complete to your chosen scope, event log, and save/load.