Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THE GENERAL PROBLEM: Password Hacking challenges a specialist to guess a secret password to defuse an explosive computer by guessing different letters contained within that

THE GENERAL PROBLEM: Password Hacking challenges a specialist to guess a secret password to defuse an explosive computer by guessing different letters contained within that word. Every wrong guess gets the computer bomb closer to going off.

The challenge starts by printing out a welcome message to the specialist 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 specialist 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 specialist'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 computer 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 specialist wins by guessing all of the correct letters in the secret word. When the specialist wins the game, you should print to the console that he has won, along with the secret word.

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

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

THE TASKS:

Each part is to build upon each other and if possible if you could leave them separate that would be helpful...

Part 1: You are to create the basic program, showing letters for ONE fixed secret word simulation 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 simulation, the specialist is trying to guess the same secret word) You should use your own functions when creating the basic program. Be sure to prompt the user to end the program at the end of 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)

Part 2:

You are to expand upon your part 1 program:

You will permit the user to run the program again after the conclusion of the first execution. The user can play as many times, 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 complete execution 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 execution, or round, the specialist chooses to play as read from the external file.For example, my program reads in 5 secret words from an external file named which contains the following secret words, one word per line in the text file. The game would have multiple 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: pig

Game #2 = secret word: mouse

Game #3 = secret word: cat

Game #4 = secret word = cow

Game #5 = secret word = dog

Game #6 = secret word: zebra

Game #7 = secret word: rat

...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)

Part 3:

You are to expand upon your program, 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...

dog, I bark!

pig, I oink!

cat, I meow!

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 OR the player can only guess a single letter per round)

part 4:

You are to refactor your program to be object oriented in nature and still accomodate all functionality required in activities 1 and 2 only (you do not have to accomodate hints for this activity - a list of secret words only). You should submit the following:

Create a class definition for an object called "WordList." This class definition should then be instantiated in your second .java file, as an instance of the object WordList that contains a listing of your secret words. The structure of your object should be as follows:

Object: WordList

Attributes: *any private attributes you deem necessary to implement this class definition

Methods: *constructor: required for creation of an instance of the WordList object *addWord(): adds one single word to the WordList object [public] *addWordsFromFile(): adds all words to the WordList object from a single text file [public] *getRandomWord(): returns a single word at random from the WordList object [public] *numWords(): returns how many words are in the WordList object [public] *any additional private methods you deem necessary to implementation this class definition

This should contain your main class that performs the program and uses your object.

This is your simple text file of secret words only used in previous activities. Note the filename change, which must be reflected in your source code (same as activity 3).

Remember, you 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 OR the player can only guess a single letter per round)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions