Giter VIP home page Giter VIP logo

snakeandladder's Introduction

Snake and Ladders Game:

Welcome to the Snake and Ladders game! Refer to this article: Enhancing a Classic: Design Patterns in Snake & Ladders

This project implements the classic board game of Snake and Ladders in Java. It demonstrates various programming concepts and potential design patterns.

Design Patterns Used:

1. Observer Pattern:

The GameEventListener interface and its implementations allow for decoupled communication between the Game class and other components that want to be notified of game events (dice rolls, player movements, game over).

Factory Pattern:

This pattern is used to create different types of game boards and dice.

Strategy Pattern:

This pattern is implemented for different dice rolling mechanisms (e.g., fair dice, custom dice).

How to Play:

Setup:

  1. Create a board with classic config or a desired size (number of squares) and configure snake and ladder positions.
    • Choose 1 when asked to choose board configuration to use classic configurations.
    • Choose 2 to add custom configurations for a board.
  2. Define players.
    • Enter number of players.
    • Keep on adding names for the players.
  3. Optionally, create and register custom listeners implementing GameEventListener to receive game event notifications.

Gameplay:

Players take turns rolling a die. The player moves their piece forward the number of spaces indicated by the die roll. If the player lands on the head of a ladder, they climb up to the ladder's top square. If the player lands on the head of a snake, they slide down to the snake's tail square. The first player to reach the final square (the last square of board) wins the game.

Running the Game:

  1. Ensure you have Java installed on your system.
  2. Clone or download the project repository.
  3. Run SnakeAndLadders.java

UML

Screenshot 2024-04-26 at 7 44 44 PM

snakeandladder's People

Contributors

simrank0 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.