first assignment of intro java course. this is the description:ImplementationAs you work, compare your output to thissample output.INITIALIZING THE GAMEThe game takes place on a horizontal line that...

first assignment of intro java course. this is the description:

Implementation


As you work, compare your output to thissample output.


INITIALIZING THE GAME


The game takes place on a horizontal line that is 20 characters wide and made up of underscores (_). At the beginning of the game, the user is asked to choose a location for the gem (*) and the player (P)—the code that asks for a location has been done for you. If the user does not want to choose, the gem (*) and player(P)should each be placed at a random position on a horizontal line. The player and the gem cannot start in the same random position. Make use of theuseful code snippetsto implement the randomization.


Once placed, the line with the player character should be printed out.The player and gem positions begin counting at zero. For example, a line whereplayer = 1would look like this:



_P__________________



PROGRESSING THE GAME


Once initialized, the program should ask what direction the user would like move: left or right. If the user enters"left", the character should move one space to the left. If the user enters"right", the character should move one space to the right. Make use of theuseful code snippetsto collect input from the user.


If the player is NOT on the same space as the gem, print a helpful message. If the difference between the player’s position and the gem’s position is:



  • Greater than or equal to 7, print“Very cold!”

  • 1 (the gem is next to the player), print“Very warm!”


Then, print the new state of the board and repeat the game progression until the gem is found.



ENDING THE GAME


Repeat “Progressing the Game” until the player “finds” the gem by landing on the space where the gem is placed. Once the gem is located:



  • Print the new state of the line with the gem instead of the player character

  • Print out “Found the gem!” for the player


When you're finished with the assignment, please download your .java file from Repl.it and upload it using the file uploader below.



and here is sample out of what the finished code should do:





Enter 0-19 for gem position or -1 to randomize: 14
Enter 0-19 for player position or -1 to randomize: 9
_________P__________
Enter a direction (left or right): left
________P___________
Enter a direction (left or right): left
Very cold!
_______P____________
Enter a direction (left or right): right
________P___________
Enter a direction (left or right): right
_________P__________
Enter a direction (left or right): right
__________P_________
Enter a direction (left or right): right
___________P________
Enter a direction (left or right): right
____________P_______
Enter a direction (left or right): right
Very warm!
_____________P______
Enter a direction (left or right): right
______________*_____
Found the gem!

Feb 06, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here