diff --git a/src/main/java/com/mattrixwv/matrix/IntegerMatrix.java b/src/main/java/com/mattrixwv/matrix/IntegerMatrix.java index 4ab474f..76ea193 100644 --- a/src/main/java/com/mattrixwv/matrix/IntegerMatrix.java +++ b/src/main/java/com/mattrixwv/matrix/IntegerMatrix.java @@ -120,6 +120,22 @@ public class IntegerMatrix{ public IntegerMatrix(IntegerMatrix matrix){ setGrid(matrix.grid); } + public IntegerMatrix(int rows, int cols, int fill){ + if(rows <= 0){ + throw new InvalidGeometryException("A filled matrix must have at least 1 row"); + } + else if(cols <= 0){ + throw new InvalidGeometryException("A filled matrix must have at least 1 column"); + } + else{ + grid = new int[rows][cols]; + for(int row = 0;row < rows;++row){ + for(int col = 0;col < cols;++col){ + grid[row][col] = fill; + } + } + } + } //Gets public int get(int row, int col){