Skip to content

Commit

Permalink
Add: 지뢰 밟으면 시스템 종료
Browse files Browse the repository at this point in the history
  • Loading branch information
kyupid committed Dec 14, 2020
1 parent ec70e8e commit 09e729b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Game.java
Expand Up @@ -21,6 +21,7 @@ class Game {
printAll();
getDirPlayer();
movePlayer(dir);
endGame();
}
}

Expand Down Expand Up @@ -98,4 +99,24 @@ private void printAll() {
System.out.println();
}
}

private void endGame() {
int temp1 = 0, temp2 = 1, temp3 = 2, temp4 = 3;
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map.length; j++) {
if (map[i][j].equals(PLAYER)) {
temp1 = i;
temp2 = j;
}
if (map[i][j].equals(MINE)) {
temp3 = i;
temp4 = j;
}
}
}
if (temp1 == temp3 && temp2 == temp4){
System.out.println("지뢰를 밟았습니다.");
System.exit(0);
}
}
}

0 comments on commit 09e729b

Please sign in to comment.