Rainbow Explosion Hangman App

Tiffany White,

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

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:

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:

Messy. I needed to use a for loop to iterate, an if/else conditional, and a do/while loop.

I thought about it and consulted her with my code. She gave me more advice– use .contains() to see if a char is in a string. Yes.

So my code looks like this: [2]

After some trial and error, scope and return statement issues, it ran. It does not run correctly. Here is the output from my terminal:

 

I had to Ctrl-C to get out of it.

Back to the drawing board.

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

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:

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:

Messy. I needed to use a for loop to iterate, an if/else conditional, and a do/while loop.

I thought about it and consulted her with my code. She gave me more advice– use .contains() to see if a char is in a string. Yes.

So my code looks like this: [2]

After some trial and error, scope and return statement issues, it ran. It does not run correctly. Here is the output from my terminal:

 

I had to Ctrl-C to get out of it.

Back to the drawing board.

© tiff.RSS