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
9731077
Police
Commits
6797a5f1
Commit
6797a5f1
authored
5 years ago
by
9731077
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug + finished Robber class
parent
a0959836
master
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
Robber.java
Robber.java
+13
-10
No files found.
Robber.java
View file @
6797a5f1
import
java.util.*
;
public
class
Robber
{
private
int
x
,
y
,
moveNum
;
private
int
x
;
private
int
y
;
private
int
moveNum
;
public
void
setY
(
int
y
)
{
this
.
y
=
y
;
...
...
@@ -15,6 +17,7 @@ public class Robber {
this
.
moveNum
=
moveNum
;
}
public
int
getY
()
{
return
y
;
}
...
...
@@ -27,37 +30,37 @@ public class Robber {
return
moveNum
;
}
public
void
moveRandomly
(
int
length
,
int
width
)
{
public
void
moveRandomly
(
int
m
,
int
n
)
{
Random
randomGenerator
=
new
Random
();
moveNum
++;
if
(
x
!=
0
&&
x
!=
length
-
1
&&
y
!=
0
&&
y
!=
width
-
1
)
{
if
(
x
!=
0
&&
x
!=
m
-
1
&&
y
!=
0
&&
y
!=
n
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
3
)
-
1
;
int
ry
=
randomGenerator
.
nextInt
(
3
)
-
1
;
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
x
==
0
&&
y
!=
0
&&
y
!=
width
-
1
)
{
if
(
x
==
0
&&
y
!=
0
&&
y
!=
n
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
2
);
int
ry
=
randomGenerator
.
nextInt
(
3
)
-
1
;
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
y
==
0
&&
x
!=
0
&&
x
!=
length
-
1
)
{
if
(
y
==
0
&&
x
!=
0
&&
x
!=
m
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
3
)
-
1
;
int
ry
=
randomGenerator
.
nextInt
(
2
);
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
x
==
length
-
1
&&
y
!=
0
&&
y
!=
width
-
1
)
{
if
(
x
==
m
-
1
&&
y
!=
0
&&
y
!=
n
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
2
)
-
1
;
int
ry
=
randomGenerator
.
nextInt
(
3
)
-
1
;
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
y
==
width
-
1
&&
x
!=
0
&&
x
!=
length
-
1
)
{
if
(
y
==
n
-
1
&&
x
!=
0
&&
x
!=
m
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
3
)
-
1
;
int
ry
=
randomGenerator
.
nextInt
(
2
)
-
1
;
x
=
x
+
rx
;
...
...
@@ -69,19 +72,19 @@ public class Robber {
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
x
==
length
-
1
&&
y
==
0
)
{
if
(
x
==
m
-
1
&&
y
==
0
)
{
int
rx
=
randomGenerator
.
nextInt
(
2
)
-
1
;
int
ry
=
randomGenerator
.
nextInt
(
2
);
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
x
==
0
&&
y
==
width
-
1
)
{
if
(
x
==
0
&&
y
==
n
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
2
);
int
ry
=
randomGenerator
.
nextInt
(
2
)
-
1
;
x
=
x
+
rx
;
y
=
y
+
ry
;
}
if
(
x
==
length
-
1
&&
y
==
width
-
1
)
{
if
(
x
==
m
-
1
&&
y
==
n
-
1
)
{
int
rx
=
randomGenerator
.
nextInt
(
2
)
-
1
;
int
ry
=
randomGenerator
.
nextInt
(
2
)
-
1
;
x
=
x
+
rx
;
...
...
This diff is collapsed.
Click to expand it.
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