Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
police
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9611046
police
Commits
8dd280cc
Commit
8dd280cc
authored
Apr 18, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makes move function
parent
234fc831
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
8 deletions
+78
-8
Police.java
src/Police.java
+78
-8
No files found.
src/Police.java
View file @
8dd280cc
...
@@ -4,26 +4,96 @@ public class Police {
...
@@ -4,26 +4,96 @@ public class Police {
Random
rand
=
new
Random
();
Random
rand
=
new
Random
();
Land
policeLand
;
Land
policeLand
;
private
int
x
;
private
int
y
;
int
firstx
=
rand
.
nextInt
(
policeLand
.
getLength
());
public
void
setFirstxy
()
{
int
firsty
=
rand
.
nextInt
(
policeLand
.
getLength
());
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
;
}
}
case
5
:
//North west
if
(
y
>
0
)
{
if
(
x
>
0
)
{
y
+=
1
;
x
-=
1
;
}
}
case
6
:
//Southeast
if
(
y
+
1
<
policeLand
.
getWidth
())
{
if
(
x
+
1
<=
policeLand
.
getLength
())
{
y
+=
1
;
x
+=
1
;
break
;
}
}
case
7
:
//Southwest
private
int
x
=
firstx
;
if
(
y
+
1
<
policeLand
.
getWidth
())
{
private
int
y
=
firsty
;
if
(
x
>
0
)
{
y
+=
1
;
x
-=
1
;
break
;
public
void
move
(){
}
}
}
int
[][]
availgitableRout
=
}
}
public
void
setLand
(
Land
myLand
)
{
public
void
setLand
(
Land
myLand
)
{
policeLand
=
myLand
;
policeLand
=
myLand
;
}
}
public
int
getX
(){
public
int
getX
()
{
return
x
;
return
x
;
}
}
public
int
getY
(){
public
int
getY
()
{
return
y
;
return
y
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment