Commit 8dd280cc authored by 9611046's avatar 9611046

makes move function

parent 234fc831
......@@ -4,26 +4,96 @@ public class Police {
Random rand = new Random();
Land policeLand;
private int x;
private int y;
int firstx = rand.nextInt(policeLand.getLength());
int firsty = rand.nextInt(policeLand.getLength());
public void setFirstxy() {
x = rand.nextInt(policeLand.getLength());
y = rand.nextInt(policeLand.getLength());
}
public void move() {
int a = rand.nextInt(8);
switch (a) {
case 0:
//Right
if (x + 1 <= policeLand.getLength()) {
x += 1;
break;
}
case 1:
//Left
if (x > 0) {
x -= 1;
break;
}
case 2:
//Up
if (y > 0) {
y -= 1;
break;
}
case 3:
//Down
if (y + 1 < policeLand.getWidth()) {
y += 1;
}
case 4:
//North East
if (y > 0) {
if (x + 1 <= policeLand.getLength()) {
y += 1;
x += 1;
}
}
private int x = firstx;
private int y = firsty;
case 5:
//North west
if (y > 0) {
if (x > 0) {
y += 1;
x -= 1;
}
}
public void move(){
case 6:
//Southeast
if (y + 1 < policeLand.getWidth()) {
if (x + 1 <= policeLand.getLength()) {
y += 1;
x += 1;
break;
}
}
case 7:
//Southwest
if (y + 1 < policeLand.getWidth()) {
if (x > 0) {
y += 1;
x -= 1;
break;
}
}
int[][] availgitableRout =
}
}
public void setLand(Land myLand) {
policeLand = myLand;
}
public int getX(){
public int getX() {
return x;
}
public int getY(){
public int getY() {
return y;
}
......
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