To represent a moor, we realize a class `Moor` that exports the
following functionalities:

- construction of a random moor, given the number of rows, the number of columns, and a real value in the range [0..1] representing the probability that a generic zone is a zone of land;
- return of the number of rows;
- return of the number of columns;
- check if the zone with coordinates <
*r*,*c*> is of land.

In realizing the class, we choose to represent the moor by means of a matrix of
`boolean`, in which the value `true` represents a land zone, and
the value `false` represents a water zone.

public class Moor { private boolean[][] moor; public Moor(int rows, int columns, double probLand) { moor = new boolean[rows][columns]; for (int r = 0; r < rows; r++) for (int c = 0; c < columns; c++) moor[r][c] = (Math.random() < probLand); } public int getNumRows() { return moor.length; } public int getNumColumns() { return moor[0].length; } public boolean land(int r, int c) { return (r >= 0) && (r < moor.length) && (c >= 0) && (c < moor[0].length) && moor[r][c]; } public String toString() { String res = ""; for (int r = 0; r < moor.length; r++) { for (int c = 0; c < moor[0].length; c++) res = res + (moor[r][c]? "*" : "o"); res = res + "\n"; } return res; } }