Commit 8e79b040 authored by hosein's avatar hosein

playground -> show | void added

parent 9ae3085f
...@@ -15,7 +15,18 @@ public class PlayGround { ...@@ -15,7 +15,18 @@ public class PlayGround {
} }
public void show() { public void show() {
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
if (ground[i][j] == 0)
System.out.print("-");
else if (ground[i][j] == 1) // police
System.out.print("X");
else // Dozd
System.out.print("*");
}
System.out.println("");
}
} }
public void putRandom(int policeNumber) { public void putRandom(int policeNumber) {
...@@ -27,7 +38,7 @@ public class PlayGround { ...@@ -27,7 +38,7 @@ public class PlayGround {
j = rand.nextInt(); j = rand.nextInt();
if (ground[i][j] == 0) if (ground[i][j] == 0)
ground[i][j] = 1; ground[i][j] = 1;
else k--; else k--;
} }
else System.out.println("Error!! police numbers are higher than n*m"); else System.out.println("Error!! police numbers are higher than n*m");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment