Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be in java You will make a simple game where the user creates a wild jungle and navigates around the world exploring various animals

Must be in java

You will make a simple game where the user creates a wild jungle and navigates around the world exploring various animals and adding them to the observed animals list!

Here are the instructions:

At the beginning of the program, introduce the program and explain to the user how the game works:

Welcome to the jungle world creator!

In this game, you will be inserting animals in certain places in the world that you create! You will also be allowed to remove animals from certain locations before you start exploring!

Once you start exploring, you will navigate around the world to observe the animals that you have inserted.

The game will keep track of all the animals you have observed!

You will be using 3 parallel two-dimensional arrays for this program as well as a 1D array:

2D String array to create the visible world the user navigates in.

2D String array that keeps track of animals in the world.

2D boolean array that keeps track of whether the spot was explored or not.

1D String array to keep track of observed animals. Its length should be the length of world*width of the world.

Notes:

Make sure to initialize all the values in the boolean array to false, except the starting position (0,0) is set to true.

Make sure to initialize all the values in the animalWorld and observedAnimals array to be because otherwise it will be initialized to null and you need to deal with it using if statements.

Make the 2D boolean array a global variable and initialize it only in the main method.

You must have the following methods created and used within your program:

makeWorld(String[][] world, int posX, int posY) ? This methods basically sets up the visible world. Assigning * to unexplored areas and O to explored areas. It also sets the users current position: (posX,posY) to a string of your choosing, example x. At the end of the method and after assigning new Strings using loops and if statements, it returns the 2D String array world.

printMainMenu()? Prints:

1. Insert an animal into the world

2. Remove an animal from the world

3. Explore the world

printMoveMenu() ? Prints:

W. Move Forward

A. Move Left

S. Move Backward

D. Move Right

I. Display observed animals

N. Sort the observed animals list by alphabetical order

E. Exit

insertAnimalToWorld(String[][] animalLocations) ? Prompts the user to enter the x and y coordinate as well as their desired animal name and inserts it to the world in the location [x,y]as long as:

- The x and y coordinates are in the worlds boundaries

- The area [x,y] is not occupied by another animal

If the conditions are not met prompt the user to enter the coordinates as well as the animal name again until the conditions above are met.

removeAnimalFromWorld(String[][] animalLocations)? Prompts the user to enter the x and y coordinate and removes the animal from the world in the location [x,y] as long as:

- The x and y coordinates are in the worlds boundaries

- The area [x,y] is not empty (contains an animal)

If the conditions are not met prompt the user to enter the coordinates until the conditions above are met.

Hint: To remove the animal you can just set the String at [x,y] to .

isEmptyBlock(String[][] animalWorld, int x, int y) ? Returns false if the array has an animal at [x,y] and true if [x,y] is empty.

updateObservedAnimals(String[] observedAnimals, String animal) ? adds animal into the observedAnimals array into the first occurrence of an empty String and returns the observedAnimals array.

printWorld(String[][] world) ? Prints the world in a grid/tabular format.

move(String[][] world, int x, int y, String[] observedAnimals, String[][] animalLocations) ? This method calls the makeWorld method to create a new world with the new user position and sets the 2D boolean array at [x,y] to be true, setting this area as explored. If [x,y] has an animal display the animal name and add it to the observed animals list and print the observed animals list, otherwise display you did not encounter anything :( . This method returns world at the end.

explore(String[][] world, String[][] animalLocations, String[] observedAnimals) ? Starts the exploration! This method prints out the world and then the move menu and asks the user to choose from the move menu until the user chooses to exit. In this method, make sure to declare the x and y variables that keep track of the users position in the world. When the user chooses to move forward for example, change the x and y values accordingly and make sure they are within the worlds bounds, if they are, call the move method and print the world, otherwise reset the position to 0,0 and tell the user that they went off bounds.

printObservedAnimals(String[] observedAnimals) ? Prints the observedAnimals list by printing each animal on one line separated by a space.

isExplored(int x, int y) ? Returns true if [x,y] is explored and false if [x,y] is not explored.

sortAnimalList(String[] observedAnimals) ? Sorts the observedAnimals list in alphabetical order using either the Bubble Sort or Selection Sort algorithms. You are NOT allowed to use Arrays.sort() for this method.

You are also free to use any additional methods if you 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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago