Question: *JAVA* Here's what output should look like. Welcome to Mine Sweeper! What width of map would you like (3 - 20): three Expected a number
*JAVA* Here's what output should look like.
Welcome to Mine Sweeper! What width of map would you like (3 - 20): three Expected a number from 3 to 20. 2 Expected a number from 3 to 20. 5 What height of map would you like (3 - 20): 22 Expected a number from 3 to 20. ten or eleven Expected a number from 3 to 20. 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . row: 12 Expected a number from 1 to 10. 5 column: red Expected a number from 1 to 5. 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Would you like to play again (y/n)? yes!! What width of map would you like (3 - 20): 4 What height of map would you like (3 - 20): 4 . . . . . . . . . . . . . . . . row: 5 Expected a number from 1 to 4. 4 column: 4 . . . . . . . . . . . . . . . Would you like to play again (y/n)? nope Thank you for playing Mine Sweeper!
import java.util.Random;
import java.util.Scanner;
public class MineSweeper {
/**
* This is the main method for Mine Sweeper game!
* This method contains the within game and play again loops and calls
* the various supporting methods.
*
* @param args (unused)
*/
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
System.out.println("Welcome to Mine Sweeper!");
}
/**
* This method prompts the user for a number, verifies that it is between min
* and max, inclusive, before returning the number.
*
* If the number entered is not between min and max then the user is shown
* an error message and given another opportunity to enter a number.
* If min is 1 and max is 5 the error message is:
* Expected a number from 1 to 5.
*
* If the user enters characters, words or anything other than a valid int then
* the user is shown the same message. The entering of characters other
* than a valid int is detected using Scanner's methods (hasNextInt) and
* does not use exception handling.
*
* Do not use constants in this method, only use the min and max passed
* in parameters for all comparisons and messages.
* Do not create an instance of Scanner in this method, pass the reference
* to the Scanner in main, to this method.
* The entire prompt should be passed in and printed out.
*
* @param in The reference to the instance of Scanner created in main.
* @param prompt The text prompt that is shown once to the user.
* @param min The minimum value that the user must enter.
* @param max The maximum value that the user must enter.
* @return The integer that the user entered that is between min and max,
* inclusive.
*/
public static int promptUser(Scanner in, String prompt, int min, int max) {
return -99; //FIXME
}
/**
* This initializes the map char array passed in such that all
* elements have the Config.UNSWEPT character.
* Within this method only use the actual size of the array. Don't
* assume the size of the array.
* This method does not print out anything. This method does not
* return anything.
*
* @param map An allocated array. After this method call all elements
* in the array have the same character, Config.UNSWEPT.
*/
public static void eraseMap(char[][] map) {
return; //FIXME
}
/**
* This prints out a version of the map without the row and column numbers.
* A map with width 4 and height 6 would look like the following:
* . . . .
* . . . .
* . . . .
* . . . .
* . . . .
* . . . .
* For each location in the map a space is printed followed by the
* character in the map location.
* @param map The map to print out.
*/
public static void simplePrintMap(char[][] map) {
return; //FIXME
}
Config.java below:
public class Config {
/**
* The minimum and maximum size, inclusive, for the width and height of the map.
*/
public static final int MIN_SIZE = 3;
public static final int MAX_SIZE = 20;
/**
* Constants with characters showing the status of different locations on the map
*/
public static final char HIDDEN_MINE = '*'; // at end of game, show a hidden mine
public static final char SWEPT_MINE = '@'; // at end of game, show swept/exploded mine
public static final char UNSWEPT = '.';
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
