Starting Piece Shape and Maps, WIP: wrong algorithm

This commit is contained in:
2023-02-27 00:52:19 +01:00
parent 4055f12fba
commit e06abe60de
4 changed files with 179 additions and 0 deletions

View File

@ -0,0 +1,40 @@
package school_project;
public class Shape {
protected boolean[][] matrix;
protected int height, width;
public Shape() {
matrix = new boolean[0][0];
}
public Shape(boolean[][] matrix){
this.setShape(matrix);
}
public void setShape(boolean[][] matrix) throws IllegalArgumentException{
height = matrix.length;
width = matrix[0].length;
for (boolean[] row: matrix){
if(row.length != width){
throw new IllegalArgumentException("The argument should be a square matrix");
}
}
this.matrix = matrix;
}
public int getHeight() {
return height;
}
public int getWidth() {
return width;
}
public boolean[][] getShape() {
return matrix;
}
}