Skip to content

Riftaricus/Mastermindv2

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Mastermind 2.0

A console-based Mastermind game written in Java. This project is an improved version of Mastermind 1.0 and demonstrates clean structure, methods, arrays, loops, input validation, and exception handling.


๐Ÿ“Œ Features

  • Difficulty levels:

    • Easy (4 positions, 6 colors)
    • Medium (5 positions, 8 colors)
    • Hard (6 positions, 10 colors)
  • Player chooses the maximum number of attempts (between 5 and 15)

  • Randomly generated secret code

  • Feedback system:

    • Black pin = correct color, correct position
    • White pin = correct color, wrong position
  • Input validation with try/catch

  • Structured code using methods and class fields


๐Ÿ“‚ Project Structure

mastermind/
 โ”œโ”€โ”€ Mastermind.java
 โ””โ”€โ”€ MastermindFuncties.java
  • Mastermind.java Starts the application and calls the game logic.

  • MastermindFuncties.java Contains all game functionality such as:

    • Game flow
    • Difficulty selection
    • Code generation
    • Game loop
    • Input validation

โ–ถ How to Run

  1. Open the project in an IDE (for example IntelliJ IDEA, Eclipse, or VS Code).
  2. Make sure both files are inside the mastermind package.
  3. Run Mastermind.java.

๐ŸŽฎ How to Play

  1. Start the game.
  2. Choose a difficulty level (1, 2, or 3).
  3. Choose the maximum number of attempts.
  4. Watch out! Because colors can be reused, meaning the code could be green green blue red or green blue blue blue.
  5. Enter your guesses as colors separated by spaces, for example:
red blue green yellow
  1. After each guess you will receive feedback:

    • Black pin = correct color in the correct position
    • White pin = correct color in the wrong position
  2. Guess the full code before your attempts run out to win the game.


๐Ÿ›  Techniques Used

This project demonstrates the use of:

  • Classes and methods
  • Arrays
  • for, while and do-while loops
  • if/else and switch-case
  • try/catch exception handling
  • Scanner for user input
  • Random for generating the secret code
  • Clean program structure and separation of responsibilities

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%