Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your task is to recreate this game in Java, albeit in a simpler, text-based format. The player enters sequences of three numbers to see if

Your task is to recreate this game in Java, albeit in a simpler, text-based format. The player enters sequences of three numbers to see if they follow the hidden rule. When the player has entered their sequence, the program should reply whether or not the sequence followed the rule. You can use the same rule or create your own. Regardless, the game is played the same way.

Instructions:

Create a loop which gives the player instructions on what to input. Then read input from the player. The input will be either one of three options: - If the user enters the word \answer" or some other string you choose to indicate the player is ready to end the game and guess. { In this case, prompt the user to guess our game's rule, then output the answer. { You don't have to tell the user if he guessed the rule correctly; it would be beyond the scope of this Lab. - Three numbers separated by spaces. { Let's call a trio of numbers and the corresponding output a Guess. Once a user makes a Guess, we will store it (how? see below). { If the user enters a sequence that follows the rules, output \Yes!" { Otherwise output \No." - If the user enters the word \previous", display all the previous Guesses the user made (the numbers and whether they were right or wrong) - Treat any other entry as an exception.

- You will be storing your answers in an ArrayList of Guess objects. A Guess is a very simple. It should hold three numbers1 and have a toString() method to make printing out its contents easier.

- Only use Scanner.nextLine() to read in input. Using Scanner.nextInt() and Scanner.nextLine() together will lead to confusion.

- To turn a string into a number, use Integer.parseInt( theString) or Double.parseInt( theString).

- Break up individual tasks into methods. For example you can have one method to grab user input, another method to detect whether a guess follows a rule, and to print all the Guess objects stored in an ArrayList.

Please give help for this one using JAVA by following the instructions and with explaination for each step. The overstriking instructions are special ones that should be followed in this case, and others are the general intructions.

Here are the instructions that final program should have.

1. The user inputs three numbers and the program tells whether or not they follow the hidden rule.

2. The user input \answer" ends the game.

3. The try catch block ensures the program does not crash.

4. Guesses are stored in an ArrayList and can be recalled by entering the word "previous."

5. The code is relatively organized and does not resemble a mass of spaghetti.

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

=+7 How has the COVID-19 pandemic impacted the operations of IHRM?

Answered: 1 week ago