Class Diagram
Class Diagram
-board: Board
-players: List<Player>
-currentPlayer: Player
+startGame()
-initializeBoard()
+playGame()
-playerRollDice(player: Player): int
-movePlayerPiece(player: Player, spaces: int)
-checkLandingSpace(player: Player): Space
-buyProperty(player: Player, property: Property)
-payRent(player: Player, property: Property)
-drawCard(): Card
-applyCardEffects(player: Player, card: Card)
-payFee(player: Player, fee: Fee)
-goToJail(player: Player)
-useGetOutOfJailFreeCard(player: Player, card: Card)
-attemptRollDoubles(player: Player): boolean
-releaseFromJail(player: Player)
-endTurn()
-checkWinCondition(): Player
+endGame()
}
class Board {
-spaces: List<Space>
-updateSpace(space: Space)
-getPropertyLocation(property: Property): int
}
class Space {
-type: SpaceType
}
class Property {
-name: string
-owner: Player
-price: int
-rent: int
}
class Fee {
-name: string
-amount: int
}
class Card {
-type: CardType
-description: string
-effect: CardEffect
}
enum SpaceType {
PROPERTY
CHANCE
COMMUNITY_CHEST
FEE
JAIL
GO_TO_JAIL
}
enum CardType {
CHANCE
COMMUNITY_CHEST
}
enum CardEffect {
MOVE_SPACES
GAIN_MONEY
LOSE_MONEY
GO_TO_JAIL
GET_OUT_OF_JAIL_FREE
}
class Player {
-name: string
-balance: int
-currentSpace: int
-isInJail: boolean
-jailTurns: int
-hasGetOutOfJailFreeCard: boolean
+rollDice(): int
+chooseToBuyProperty(property: Property): boolean
+chooseToUseGetOutOfJailFreeCard(card: Card): boolean
}
Game --> Board
Game --> Player
Game *--> Space
Game *--> Fee
Game *--> Card
Board *--> Space
Player --> Card
Property --> Player