Skip to content

Commit b0ce075

Browse files
author
Arun Prasaad
committed
Improve naming
1 parent 22ef847 commit b0ce075

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/main/java/ihm/Editor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public void mousePressed(MouseEvent e) {
270270
if (e.getX() < windowWidth + 31 && e.getY() < windowHeight + 31) {
271271
int l = Math.max((e.getX() - X_OFFSET) / TILE_SIZE, 0);
272272
int c = Math.max((e.getY() - TILE_SIZE) / TILE_SIZE, 0);
273-
controller.getWarehouse().getCase(c, l).setContent(content);
273+
controller.getWarehouse().getCell(c, l).setContent(content);
274274
repaint();
275275
}
276276
}
@@ -303,7 +303,7 @@ private boolean isValidLevel() {
303303
IntStream.range(0, rowCount * columnCount).forEach(i -> {
304304
int c = i / columnCount;
305305
int l = i % columnCount;
306-
TileType tileType = controller.getWarehouse().getCase(c, l).getContent();
306+
TileType tileType = controller.getWarehouse().getCell(c, l).getContent();
307307
tileCounts.merge(tileType, 1, Integer::sum);
308308
});
309309

@@ -319,7 +319,7 @@ private void saveLevelToFile() {
319319
IntStream.range(0, rowCount * columnCount).forEach(i -> {
320320
int c = i / columnCount;
321321
int l = i % columnCount;
322-
TileType tileType = controller.getWarehouse().getCase(c, l).getContent();
322+
TileType tileType = controller.getWarehouse().getCell(c, l).getContent();
323323
levelContent.append(tileType.getCode());
324324

325325
if ((i + 1) % columnCount == 0) { // the row is complete

src/main/java/ihm/SokobanPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void paint( Graphics g ) {
5454
// So x <=> column and y <=> row
5555
for(int l = 0; l < controller.getWarehouse().getLines(); l++ ) {
5656
for(int c = 0; c < controller.getWarehouse().getColumns(); c++ ) {
57-
g.drawImage( images.get(controller.getWarehouse().getCase(l, c).getContent()), c * IMAGE_SIZE, l * IMAGE_SIZE, IMAGE_SIZE, IMAGE_SIZE, null);
57+
g.drawImage( images.get(controller.getWarehouse().getCell(l, c).getContent()), c * IMAGE_SIZE, l * IMAGE_SIZE, IMAGE_SIZE, IMAGE_SIZE, null);
5858
}
5959
}
6060
}

src/main/java/logic/Cell.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ public void setContent (TileType content) {
2626

2727
public void setAdjacentCellContent(Direction direction, TileType content) {
2828
switch (direction) {
29-
case UP -> warehouse.getCase(line - 1, column).setContent(content);
30-
case DOWN -> warehouse.getCase(line + 1, column).setContent(content);
31-
case LEFT -> warehouse.getCase(line, column - 1).setContent(content);
32-
case RIGHT -> warehouse.getCase(line, column + 1).setContent(content);
29+
case UP -> warehouse.getCell(line - 1, column).setContent(content);
30+
case DOWN -> warehouse.getCell(line + 1, column).setContent(content);
31+
case LEFT -> warehouse.getCell(line, column - 1).setContent(content);
32+
case RIGHT -> warehouse.getCell(line, column + 1).setContent(content);
3333
}
3434
}
3535

3636
public TileType getAdjacentCellContent(Direction direction) {
3737
return switch (direction) {
38-
case UP -> warehouse.getCase(line - 1, column).getContent();
39-
case DOWN -> warehouse.getCase(line + 1, column).getContent();
40-
case LEFT -> warehouse.getCase(line, column - 1).getContent();
41-
case RIGHT -> warehouse.getCase(line, column + 1).getContent();
38+
case UP -> warehouse.getCell(line - 1, column).getContent();
39+
case DOWN -> warehouse.getCell(line + 1, column).getContent();
40+
case LEFT -> warehouse.getCell(line, column - 1).getContent();
41+
case RIGHT -> warehouse.getCell(line, column + 1).getContent();
4242
};
4343
}
4444

src/main/java/logic/Controller.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,28 @@ public void action(Direction direction) {
5454
switch (direction) {
5555
case UP -> {
5656
if (l != 0) {
57-
if (warehouse.getCase((l - 1), c).canAcceptWorker(direction)) {
57+
if (warehouse.getCell((l - 1), c).canAcceptWorker(direction)) {
5858
worker.moveUp();
5959
}
6060
}
6161
}
6262
case DOWN -> {
6363
if (l != warehouse.getLines() - 1) {
64-
if (warehouse.getCase((l + 1), c).canAcceptWorker(direction)) {
64+
if (warehouse.getCell((l + 1), c).canAcceptWorker(direction)) {
6565
worker.moveDown();
6666
}
6767
}
6868
}
6969
case LEFT -> {
7070
if (c != 0) {
71-
if (warehouse.getCase(l, c - 1).canAcceptWorker(direction)) {
71+
if (warehouse.getCell(l, c - 1).canAcceptWorker(direction)) {
7272
worker.moveLeft();
7373
}
7474
}
7575
}
7676
case RIGHT -> {
7777
if (c != warehouse.getColumns() - 1) {
78-
if (warehouse.getCase(l, c + 1).canAcceptWorker(direction)) {
78+
if (warehouse.getCell(l, c + 1).canAcceptWorker(direction)) {
7979
worker.moveRight();
8080
}
8181
}

src/main/java/logic/Warehouse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void parseLevel(Worker worker, List<String> linesFromFile) {
7171
}
7272

7373

74-
public Cell getCase(int l, int c) {
74+
public Cell getCell(int l, int c) {
7575
return cells.get(l*this.columns + c);
7676
}
7777

0 commit comments

Comments
 (0)