Class PentominoBuilder
java.lang.Object
PentominoBuilder
This class contains all the methods that you may need to start developing your project together with the representation of the pentomino's pieces
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[][][]eraseDuplicates(int[][][] data) Erase duplicates in a array of matrices The input matrix stays unchangedstatic int[][]eraseEmptySpace(int[][] data) Erase rows and columns that contain only zerosstatic int[][]horizontalFlip(int[][] data) Flip the matrix horizontally It makes a copy, the input matrix stays unchangedstatic booleanisEqual(int[][] data1, int[][] data2) Check if two matrices are equal Assume they have the same sizestatic booleanisEqualRecursion(int[][] data1, int[][] data2, int row, int column) static voidstatic int[][]makeBigger(int[][] data, int size) Expands a smaller than size*size matrix to a size*size matrix It makes a copy, the input matrix stays unchanged Assume that the input is smaller than size!!static voidMake the database, created based on the pentomino's pieces defined in basicDatabasestatic int[][]moveToAbove(int[][] data) Move matrix to the left above corner Does not make a copy!static int[][]rotate(int[][] data, int rotation) Rotate the matrix x times over 90 degrees Assume that the matrix is a square! It does not make a copy, so the return matrix does not have to be usedstatic int[][]verticalFlip(int[][] data) Flip the matrix vertically It makes a copy, the input matrix stays unchanged
-
Field Details
-
database
-
-
Constructor Details
-
PentominoBuilder
public PentominoBuilder()
-
-
Method Details
-
makeDatabase
public static void makeDatabase()Make the database, created based on the pentomino's pieces defined in basicDatabase -
rotate
public static int[][] rotate(int[][] data, int rotation) Rotate the matrix x times over 90 degrees Assume that the matrix is a square! It does not make a copy, so the return matrix does not have to be used- Parameters:
data- : a matrixrotation- : amount of rotation- Returns:
- the rotated matrix
-
verticalFlip
public static int[][] verticalFlip(int[][] data) Flip the matrix vertically It makes a copy, the input matrix stays unchanged- Parameters:
data- : a matrix- Returns:
- the flipped matrix
-
horizontalFlip
public static int[][] horizontalFlip(int[][] data) Flip the matrix horizontally It makes a copy, the input matrix stays unchanged- Parameters:
data- a matrix- Returns:
- the flipped matrix
-
makeBigger
public static int[][] makeBigger(int[][] data, int size) Expands a smaller than size*size matrix to a size*size matrix It makes a copy, the input matrix stays unchanged Assume that the input is smaller than size!!- Parameters:
data- : a matrixsize- : the square size of the new matrix- Returns:
- the size*size matrix
-
moveToAbove
public static int[][] moveToAbove(int[][] data) Move matrix to the left above corner Does not make a copy!- Parameters:
data- : a matrix- Returns:
- the modified matrix
-
eraseDuplicates
public static int[][][] eraseDuplicates(int[][][] data) Erase duplicates in a array of matrices The input matrix stays unchanged- Parameters:
data- an array of matrices- Returns:
- the array of matrices without duplicates
-
isEqual
public static boolean isEqual(int[][] data1, int[][] data2) Check if two matrices are equal Assume they have the same size- Parameters:
data1- : the first matrixdata2- : the second matrix- Returns:
- true if equal, false otherwise
-
isEqualRecursion
public static boolean isEqualRecursion(int[][] data1, int[][] data2, int row, int column) -
eraseEmptySpace
public static int[][] eraseEmptySpace(int[][] data) Erase rows and columns that contain only zeros- Parameters:
data- a matrix- Returns:
- the shrinken matrix
-
main
- Parameters:
args-- Throws:
FileNotFoundExceptionUnsupportedEncodingException
-