Skip to content

Commit f7fc6be

Browse files
committed
Refactored
1 parent 05dee2c commit f7fc6be

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/main/java/tetris/Board.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Board implements Grid {
1010

1111
private final int rows;
1212
private final int columns;
13-
private final char[][] stationary;
13+
private char[][] stationary;
1414

1515
private Grid falling;
1616
private int fallingBlockRow;
@@ -93,16 +93,13 @@ private void startFalling(Grid piece) {
9393
}
9494

9595
private void stopFalling() {
96-
for (int row = 0; row < falling.rows(); row++) {
97-
for (int col = 0; col < falling.columns(); col++) {
98-
char cell = falling.cellAt(row, col);
99-
int boardRow = fallingBlockRow + row;
100-
int boardCol = fallingBlockColumn + col;
101-
if (cell != EMPTY && boardRow < this.rows()) {
102-
stationary[boardRow][boardCol] = cell;
103-
}
96+
char[][] newStationary = new char[rows()][columns()];
97+
for (int row = 0; row < rows(); row++) {
98+
for (int col = 0; col < columns(); col++) {
99+
newStationary[row][col] = cellAt(row, col);
104100
}
105101
}
102+
stationary = newStationary;
106103
falling = null;
107104
}
108105

0 commit comments

Comments
 (0)