Modifier and Type | Field and Description |
---|---|
private int |
col |
private int |
numTrue |
private int |
row |
private boolean[] |
truthArr |
Constructor and Description |
---|
RandPlace(int r,
int c,
int number)
This whole class is to create a boolean array
|
Modifier and Type | Method and Description |
---|---|
int |
arrTruth()
Returns the number of "true" values in the truth array
|
boolean[][] |
convert2D()
Generates a usable 2D array from the 1D array truthArr- convoluted? Granted.
|
boolean[][] |
generate2D()
Generates a usable 2D array from any passed boolean[] array- such as the one valid() makes.
|
int |
numContains(boolean truth,
boolean[] array)
numContains counts the number of "true" or "false" (truth) in an array
|
int |
numContains(boolean truth,
boolean[][] array) |
boolean[] |
valid()
Bread and butter of the class: creates a valid array (one long one) of [row*col] length, with [numTrue] "true" values
|
private int row
private int col
private int numTrue
private boolean[] truthArr
public RandPlace(int r, int c, int number)
r,
- rows of the arrayc,
- columns of the arraynumber;
- for Minesweeper this is the number of mines to be placed.IllegalArgumentException
- if numTrue is ever be greater than (row * col)public int numContains(boolean truth, boolean[] array)
truth,
- a boolean state, "true" or "false"array,
- any boolean[] arraypublic int numContains(boolean truth, boolean[][] array)
public boolean[] valid()
public int arrTruth()
public boolean[][] convert2D()
public boolean[][] generate2D()
Copyright © 2018. All rights reserved.