Code Monkey home page Code Monkey logo

hangman_cpp's Introduction

Hangman Game in C++

This project is a simple implementation of the classic Hangman game using C++. The game is designed using Object-Oriented Programming (OOP) principles, which helps in organizing the code and making it more maintainable and scalable.

Architecture

The game is encapsulated in a class named HangmanGame. This class contains both the data members and member functions that define the behavior of the game.

Data Members

  • game_over: A boolean that indicates whether the game is over.
  • choice: An integer that stores the user's menu choice.
  • random_line: An integer that stores the line number of the randomly selected word.
  • word, line, count, guess, word_length: Various private members used in the game logic.

Member Functions

  • menu(): Displays the game menu to the user.
  • add_word(): Allows the user to add a new word to the game.
  • exit_game(): Exits the game.
  • dashes_for_word(string word): Replaces the letters in the word with dashes.
  • random_line_selector(): Selects a random line number from the words file.
  • print_the_word(int random_line): Prints the word at the given line number.
  • guess_letter_in_dashed_word(string word): Allows the user to guess a letter in the word.

Object-Oriented Approach

The game is designed using the principles of OOP. The HangmanGame class encapsulates the data and functions related to the game, providing a clear interface and hiding the implementation details. This makes the code easier to understand, maintain, and modify.

How to Play

The game starts by displaying a menu with three options: Play Game, Add Word, and Exit. The user can choose to start a new game, add a new word to the game, or exit the game. During the game, the user is asked to guess a letter in the hidden word. The game continues until the user guesses the whole word or chooses to exit the game.

hangman_cpp's People

Contributors

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