Rainbow Explosion Hangman App

3 min read

So I am working on a project from last semester called Rainbow Explosion. [1]

It is a hangman app with a twist. Here is an excerpt of the instructions:

Project #3: Rainbow Explosion

The game of rainbow explosion challenges a player to guess a secret word to defuse the color bomb by guessing different letters contained within that word. Every wrong guess gets the bomb closer to going off.

The game starts by printing out a welcome message to the player with instructions and a placeholder for the secret word, represented by blank underscores (the number of underscores printed represent the number of letters in the secret word for the player to guess).

For each round of the game, the player is prompted to input a guessed letter to see if that letter is in the secret word:

If the guessed letter is contained in the secret word, the player has won that round, and the guessed word thus far is printed (consisting of blank underscores and correctly guessed letters).
If the player’s guessed letter is not in the secret word, the guessed word thus far is printed (consisting of blank underscores and any correctly guessed letters), and the player earns a “tick.”
The ticks add up. A player can only accumulate 6 incorrect ticks or he loses the game and the bomb goes off.
For each round that the player guesses a letter incorrectly, you should also print out the color that the player has failed thus far, based on how many ticks the player has:
Each tick will correspond to the bomb exploding sooner, for each incorrectly guessed letter:
* 1 tick = red
* 2 ticks = orange
* 3 ticks = yellow
* 4 ticks = green
* 5 ticks = blue
* 6 ticks = purple BOOM!!!
The player wins by guessing all of the correct letters in the secret word. When the player wins the game, you should print to the console that he has won, along with the secret word.

The player can also lose. Once all the colors are printed to the screen the game is over and the player has lost.

For the advanced versions of this game, you should also provide a hint for the secret word to the player at the beginning of the game and use OO programming to create your own class.

It is written entirely in Java and I think I talked about it a few weeks ago. Mel, a Java vet on the Code Newbie Slack team (and a woman in tech!) said for me to think about it from different angles. For instance, think about it from what letters aren’t being guessed.

So I went all in with an array of chars that I could iterate through with a for loop. It looked awful. It looked like this: