Text based Mastermind

mastermindText1This is text based version of the board game “Mastermind” programed in Java. This was my first larger Java project I made. Note that both the user interface and the comments in the source code at the bottom of this page is written in Swedish

The program starts by generating a secret color code that consists of 4 numbers between 0 and 5. Each number is then represented by a color when it is displayed to the user. The user should then try guess this secret color code that the computer has generated. When the user has made a guess, he will get feedback for each color by “?”, “vit” (white in Swedish), “svart” (black in Swedish). “?” means the color does not exists any ware in the color code, “vit” means that the color is in the color code but not at that position, “svart” means that the correct color is at the correct place.

The user interface is made using a basic dialog window. The program uses one- and two dimensional arrays to store the color codes and the data to be displayed in the window. Functions is used to generate the color code and compare color codes.

Download source code

Click here to download the source code.

I have used a free Java IDE called “jGRASP” to develop this program. The zip-folder only contain the source file. You need to compile it before you can run it.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.