OOD / Game• Patterns: Singleton
Snake & Ladder
Medium
Problem Summary
Design a modular Snake and Ladder board game supporting multiple players and custom board dimensions.
Functional Scope
- Board contains Snakes and Ladders at randomized positions.
- Process turns iteratively using a dice (1-6 rolls).
- Winning condition: Player lands exactly on slot 100.
Entity-Relationship (ER) Schema
Game [1] <---> [1] Board Game [1] <---> [*] Player Board [1] <---> [100] BoardCell BoardCell [1] <---> [0..1] Jump (Snake/Ladder)
Design Approach
Use a Queue to manage player turn sequences. Model snakes and ladders as jumping destinations on BoardCell nodes to keep board rendering and trajectory computation decoupled.
Core Classes & Models
Board (Grid of BoardCells)BoardCell (Contains optional Snake or Ladder pointer)Player (Tracks current index position)Dice (Generates random values in [1, 6])Game (Engine loop routing turns)
Code Blueprint
public class BoardCell {
private int destination;
public int getDestination() { return destination; }
}