Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with a Java project using arrays. A correct code to use as a reference for this so I can see how to

I need help with a Java project using arrays. A correct code to use as a reference for this so I can see how to structure something like this would really help.

Instructions:

image text in transcribed

Output Examples:

image text in transcribed

image text in transcribed

Create two separate programs for this project. The first program randomly creates a map that the second program uses for the game. In the game, the player searches the map looking for five treasures. After each guess, the map either shows they found a treasure ('X marks the spot), or a clue telling them if they are close to a treasure (hot 'H or cold C'). The player wins when they find all five treasures without getting captured by the pirate that patrols his treasures (P") ogram 1 - Map Generator 1. Create a 9x9 array of ''s 2. Randomly distribute 5 'X's (treasures) throughout the grid 3. Make sure that the randomizer cannot choose the same location twice and overwrite an 'X' (ie. make sure you always have 5 'X's) 4. Write the array to a file named "treasures.txt" in 9x9 format. Program 2 - Treasure Hunt Game 1. Main - create two 9x9 arrays, one for storing the map, and the other for displaying the board to the user. Also create variables to store information about the pirate 2. Load Map - create a function to read in the map from the file "treasures.txt" and stores it in a 2D array, return the array 3. Clear Board - create a function to reset the board grid with all '~s 4. Input Checks - create functions to get and return valid input (you may use the CheckInput class provided on Beachboard and add functions as needed) Take in a letter (A-I) for the row (this is a good place to convert user input from a letter to a integer for array access) Take in a number (1-9) for the column. Take in a menu option (1-2) Replay Level (Y/N) Check that the spot hasn't already been revealed a. b. c. d. e. 5. Display Board - create a function that passes in the board and the pirate's information, and then displays the board. Display the numbers 1-9 above the grid and the letters A-I along the side. Display the pirate's location when necessary 6. Get Clue - create a function that detects the treasure. Pass in the map and the location to check, examine that location and the eight spots surrounding the location the user entered. If that location has one of the treasures, return an X', if there is treasure nearby, return an 'H' for hot, otherwise return a 'C for cold Note: the program will throw an exception if you try to access a location outside the bounds of the arrav, either do a bounds check on the values, or use exception handling a. Allow the user to play the game by prompting them to enter a location, then reveal that location, but watch out, the pirate starts at a random location on the map and then randomly moves one space (up, down, left, or right) after each guess (don't allow the pirate to move off the map). Keep a counter of the number of treasures left to find and display it after every round. If they find a treasure, decrement the counter, if not, show the clue, if the clue is 'H', reveal the pirate's location, otherwise he stays hidden. If the user successfully locates all 5 treasures, then they win. If they are captured by the pirate then they lose the game. Allow them to replay the same map if they choose to

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions