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.