22.3 ANALYSIS OF SNAKE AND LADDER GAME

After studying the elements of OOAD, let us start analysis of the snake and ladder problem. Let us prepare in detail specifications of the problem.

22.3.1 Problem specification

Description of the game:

  1. Players play alternately (turn by turn).
  2. A player throws a dice.
  3. His pebble is moved on the board depending on the dice value.
  4. If the pebble is at the bottom of the ladder, move it to the top of the ladder.
  5. If the pebble is at the mouth of the snake, move it to the tail of the snake.
  6. If any player reaches Home (H100) he wins. Play ends.
  7. If pebble tries to move ahead of Home, it reverses its direction. For example, from H98 two moves take pebble to home, but three moves take it to H99.

A project starts with ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.