Skip to main content
Dat 1. Sem Efterår 2025
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Project

Monopoly (Matador) – Two‑Week One‑Pager (No Code)

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.


1) Learning goals

  • 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.

2) Minimal official scope (MVP rules)

  • 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.


3) Glossary (EN ↔ DK)

EnglishDansk (Matador)Short note
GOSTARTCollect salary when passing/landing
Bank / BankerBanken / BankørHolds money, deeds, buildings, runs auctions
TokenBrikPlayer piece
DiceTerningerTwo dice; 3 doubles → Jail
Property / Title DeedGrund / SkødeOwnable; rent charged to others
Color‑groupFarvegruppeOwn all → double base rent; enables building
RentLejePaid on landing, unless mortgaged
AuctionAuktionIf not bought when first landed
Houses / HotelsHuse / HotellerIncrease rent; build evenly (Week 2)
Chance / Community ChestPrøv lykkenCard deck(s) with instructions
JailFængselIn Jail vs Just Visiting
Get Out of Jail FreeLøsladelseskortKeep or sell; use to exit Jail
Free ParkingParkeringResting space; no payout
Income TaxIndkomstskatEdition rules vary
MortgagePantsætningCash now; interest on unmortgage
BankruptcyFallitTransfer assets; leave the game
Short GameHurtigt spilVariant policies/end conditions

4) Domain model (DDD‑lite sketch)

  • 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).

5) Pattern map (who does what)

  • State patternTurn flow & player state

    • States: StartTurn → Roll → Move → ResolveSpace → PostActions → EndTurn → NextPlayer
    • Player states: Active / InJail / Bankrupt
  • Command patternAtomic actions

    • RollDice, MoveToken, BuyProperty, PayRent, DrawCard, Auction, Mortgage, BuildHouse, EndTurn
  • Strategy patternRule variants as policies

    • SalaryPolicy, RentPolicy, TaxPolicy, JailExitPolicy, AuctionPolicy, BuildPolicy
  • Observer patternUI/log reacts to domain events

    • Events: PassedGo, LandedOn, RentCharged, BoughtProperty, WentToJail, DrewCard, BuiltHouse, Bankruptcy
  • FactoryBoard & cards from data files

    • BoardFactory, CardFactory
  • Repository/SerializationSave/Load game state (JSON or simple text)


6) Turn state chart (PlantUML)

@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

7) Pattern map diagram (PlantUML)

@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

8) Week‑by‑week checklist (deliverables)

Week 1 — Analysis → Walking skeleton (no houses/hotels yet)

  • 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

Week 2 — Core depth & persistence

  • 🔹 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

9) Roles & responsibilities (for CRC cards)

  • 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.

10) Testing strategy

  • 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.

11) Stretch ideas (optional)

  • 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.