StarBlind Game

In this assignment you will create the StarBlind game which is based on the Mastermind board game.

In your game, the computer will, at random, select colors for four stars. The user will guess the colors of the stars and receive feedback on the accuracy of their guess. Here is an example of the game play for the program:

Rules

  1. The user guesses by entering four letters representing the star colors (R - red, G - green, B - blue, Y - yellow, M - magenta, and C - cyan).
  2. The order of the letters matters
  3. Colors can be expressed with either uppercase or lowercase letters.
  4. If the user enters an invalid guess (not exactly four characters or containing letters other than R, G, B, Y, M, or C), a useful message must be displayed and the user will be given another opportunity to guess. This continues until a valid guess is entered.
  5. Green and yellow bars are used to provide feedback to the user on their guess. All green bars should appear prior to any yellow bars.
  6. Stars and Bars should be displayed in bold text. You can produce bold characters by prefixing the characters with \u001B[1m.
  7. The game continues until the user guesses all four colors correctly.
  8. Once the user wins, you should print out all the guesses they've made and then ask them if they want to play again or end the program. If the user chooses to play again, and new StarBlind game with begin with a different random chosen sequence of colors as the answer.

Software Design

You will make use of the Color enumeration from homework 10 with the addition of three class methods. For the methods that require a color code argument, valid characters (uppercase or lowercase) include R, G, B, C, M, Y, W for white, and K for black. If any other character is passed to the method, the method should return the "color" corresponding to "Reset".

There are three additional classes for you to implement.

Stars

The Stars class represents a guess made by the player (the four colored stars). This class is required to have three public constructors and two methods:

Please note that calling equals() to compare two Star or Colorobjects, will only return true if the two references point to exactly the same object. If the two references point to different objects that contain the same sequence of colored stars, equals() will return false. You learn why in the next couple of weeks. For this assignment, if you want to compare two Star or Color objects you can compare the Strings returned by their toString() methods, since the String class does have an implemented equals() method.

StarBlind

The StarBlind class represents the game. An object from this class must retain all of the guesses the user makes in an ArrayList<Stars>. This is how you will print out the list of past guesses when the user wins. This class is required to have two public constructors and four public methods:

Driver

The Driver class contains the main program and three private class methods:

StarBlindTester

A StarBlindTester class has been provided to help you test and debug your implementation. The tester will use the second StarBlind tester to create a StarBlind game where the answer color sequence is known. It then tests the guess() method with various guesses and prints out the results. Use this tester to make sure your program is producing the correct number of yellow and green bars.

For Motivated Students

Once you have completed all of the requirements for the assignment, motivated students may wish to add additional features. Some ideas:

Acknowledgement

This laboratory assignment was developed by Dr. Chris Taylor.

See your professor's instructions for details on submission guidelines and due dates.