Question: need help Problem 2-Name your class Totally NotPacman You are develo ping a new game similar to the arcade angular grid of character mustade classic

 need help Problem 2-Name your class Totally NotPacman You are develo

need help

Problem 2-Name your class Totally NotPacman You are develo ping a new game similar to the arcade angular grid of character mustade classic Pacman. Each level in the game consists of a e avoiding various enemies. Each level will be stored as a Each e certain intg various enemies. Each level wit egers represent certain components: 0 Open space Wall Enemy Main character An example level is shown below: Columns 0 2 0 0 0 0 0 0 are occupied by an enemy. For example, in the data above, there are 19 non-wall cells. Of those enemy. Thus, the difficulty would be 3/19 or about 0.158. 1. (6 pts) Let's define the "difficulty" of a level as the proportion of non-wall cells that 19, 3 are occupied by an Write a method difficulty that takes a 2D array in the above format as a parameter. The method should return the difficulty of that level. 2. (10 pts) Let's say that the main character is considered "under threat" if there are at least two enemies within the eight cells immediately surrounding the main character (all four cardinal directions, and all four diagonal directions). For example, in the level above the main character is not under threat since there are no enemies in the immediately surrounding cells. Note that there may be fewer than eight surrounding cells if the main character is on the edge of the level. Write a method isUnder Threat that takes a 2D array in the above format as a parameter. The method assume that the main character shows up exactly once in the 2D array. Be careful not to go beyond the should return whether the main character is under threat according to the definition above. You may bounds of the array! (4 pts) Write a main method that creates a 2D array with the data from the example above, then calls both of your methods and shows the results. You do not need to read any user input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!