How do I code these activities in Java programs? Each activity builds on the las
ID: 3770407 • Letter: H
Question
How do I code these activities in Java programs? Each activity builds on the last and each activity is its own program. I do not need the .txt file, I just need the program to be able to read from the external file with words of different length.
The game called Color Bomb challenges a player to guess a secret word to defuse the paint 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 "slash."
The slashes add up. A player can only accumulate 6 incorrect slashes 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 slashes the player has:
Each slash will correspond to the bomb exploding sooner, for each incorrectly guessed letter:
1 slash = Blue, 2 slashes = green, 3 slashes = purple, 4 slashes = orange, 5 slashes = red, 6 slashes = yellow 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.
ACTIVITY 1
You are to create the basic game, showing letters for ONE fixed secret word game in which you know the word when you're programming it. (Another words, you put [hard-code] the secret word in your source code, and every time you play the game, the player is trying to guess the same secret word) You should use your own functions when creating the basic game. Be sure to prompt the user to end the game / program at the end of the game.
For this activity, you do not have to do the following:
-keep track if the player already guessed a letter previously
-allow the player to guess the secret word in its entirety (the player can only guess a single letter per round)
ACTIVITY 2
You are to expand upon your Color Bomb game:
You will permit the user to play the game again after the conclusion of the first game. The user can play as many games, or rounds, as he wishes (which means that he may have to guess a secret word more than once.) The player can exit the program after the completion of any game or round.
You should obtain a list of secret words in as input from an external file to be used as the source of the secret word at the beginning of your program (so do this only once). You should ask the secret words in random order - you cycle through the list of secret words in a random order for each game, or round, the player chooses to play as read from the external file.
For example, my program reads in 5 secret words from an external file named “secretwords.txt" which contains the secret words, one word per line in the text file. (The words shouldn’t matter and should be able to be changed to prove the program can read any of the words) The game would have 5 secret words from which to play from, and the secret word would be selected from the sequence of words in a random order. A random order might look like this:
Game #1 = secret word: tug
Game #2 = secret word: ship
Game #3 = secret word: ladder
Game #4 = secret word = bag
Game #5 = secret word = house
Game #6 = secret word: tail
Game #7 = secret word: seat
...etc....until the player ends the program.
For this activity, you do not have to do the following:
-keep track if the player already guessed a letter previously
-allow the player to guess the secret word in its entirety (the player can only guess a single letter per round)
ACTIVITY 3
You are to expand upon your game of Color bomb, printing out a corresponding hint for the secret word read in from the external text file after the welcome message. You should read the secret words and their corresponding hints in from an external text file at the beginning of your program (each word and each hint are each on its own line in the external text file) and use them for the game execution. This activity is based on previous activities - so this final program must permit the player to play the game multiple times and randomly select the secret word and its hint from all of those that are possible from the file input. Your program should work with ANY text file.
Your external text file could look either way (not including the bullet points):
Option 1:
· dog, I bark!
· pig, I oink!
· cat, I meow!
Option 2:
· dog
· I bark!
· pig
· I oink!
· cat
· I meow!
(The exact words and hints do no matter, they just need to be able to be read from a file)
Additionally, for this activity, you do have to do the following:
-keep track if the player already guessed a letter previously
-allow the player to guess the secret word in its entirety (the player can only guess a single letter per round)
If something needs clarified leave a comment and I will respond ASAP
Thanks for the help!
Explanation / Answer
Program:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.