Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
chess
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
9731075
chess
Commits
00443b1f
Commit
00443b1f
authored
Apr 25, 2019
by
hosein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pawn -> canMove added
parent
e4c19f83
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
1 deletion
+34
-1
Pawn.java
src/pack/Nuts/Pawn.java
+34
-1
No files found.
src/pack/Nuts/Pawn.java
View file @
00443b1f
package
pack
.
Nuts
;
public
class
Pawn
{
public
class
Pawn
extends
Nut
{
public
Pawn
(
int
id
)
{
this
.
id
=
id
;
isAlive
=
true
;
if
(
id
>
0
)
{
x
=
6
;
y
=
id
-
1
;
}
else
{
x
=
1
;
y
=
8
+
id
;
}
}
//
// @Override
// public void move(int[] destination) {
// x = destination[0];
// y = destination[1];
// }
@Override
public
boolean
canMove
(
int
[]
destination
)
{
if
(
id
>
0
)
{
if
(
x
==
6
&&
destination
[
0
]
-
x
==
2
&&
destination
[
1
]
==
y
)
return
true
;
return
destination
[
0
]
<
x
&&
destination
[
0
]
>=
x
-
1
&&
destination
[
1
]
<=
y
+
1
&&
destination
[
1
]
>=
y
-
1
;
}
else
{
return
destination
[
0
]
>
x
&&
destination
[
0
]
<=
x
+
1
&&
destination
[
1
]
<=
y
+
1
&&
destination
[
1
]
>=
y
-
1
;
}}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
}
}
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