Question
Create a Main method that contains two 2-Dimensional arrays of characters. The first array, which we will call our visible field, needs to be 5
Create a Main method that contains two 2-Dimensional arrays of characters. The first array, which we will call our visible field, needs to be 5 by 5 and should initially hold the underscore character _. This will be used in our game of minesweeper to represent the possible locations the player can check.
The second array, which we will call our hidden field, should also be 5 by 5 but filled with the capital letter "S which means safety. However, we need to randomly replace five (5) "Ss with five (5) bombs represented by the capital letter B in this second array.
Write a recursive method (DO NOT USE A LOOP) that accepts both 2D arrays and an integer that represents what round it is, and another integer for the score. The method will work as described below.
Print out the first 2D array, our visible field, and allow the user to enter a viable position to check in that field. If they do not enter a viable position, please ask them to enter another position.
After getting a position, check that position in our second 2D array (our hidden field) and see if there is a bomb there. If no bomb is there, the player gets 1 point and that spot on the visible field becomes an S and the visible field is printed out again along with the updated round number and another position is taken from the user.
If there is a bomb there, print the hidden field along then print a message saying how many points the player got so far and that they stepped on a bomb in the final round number. This ends the game (a good spot for your base case) and no more user input should be accepted.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started