Untitled
unknown
plain_text
2 years ago
2.1 kB
4
Indexable
* Create a method that will take 2 int parameters rows and columns. This method will create * a table on the console output, representing the game of mine sweeper. The aim of this task * is to illustrate to the player where all the mines are on the board, such as what occurs in * the standard 'game over' screen for mine sweeper. * * The method should accept values between 5 and 10 for the rows and columns, however it is not * required that the value of rows should match the value of columns. * * The minimum value that must be entered for the rows and columns is 5, and the maximum is 10. Your method * should check this. If ok, then the method will continue, otherwise it should print out an error message. * * The method should print a header for the table, labelling the columns, beneath, a separator as shown in the example. * The method should then populate the table, using the character 'o' to represent clear cells and * the character 'x' to represent mines. Each row should also be labelled as 1, 2, 3, etc. * * The mines are to be specified with 2 int values, x,y such that x represents the row position, and * y represents the column position. Your method must specify three mines. * * You are expected to use String.format() in this task, to format the table. * The cells should be padded to a length of 3 with no unnecessary information to pad the cells. * (i.e. no occurrences of for example, XoX or OoO). This means each o or x must have a space on both sides. * * If for example, the table was specified with having 10 rows and 6 columns, and * the 3 mines were specified at 3,4 and 1,5 and 6,6 your table must look *exactly* like this: * | 1 2 3 4 5 6 | - - - - - - 1 | o o o o x o 2 | o o o o o o 3 | o o o x o o 4 | o o o o o o 5 | o o o o o o 6 | o o o o o x 7 | o o o o o o 8 | o o o o o o 9 | o o o o o o 10 | o o o o o o
Editor is loading...