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
9611046
chess
Commits
b0e19b0a
Commit
b0e19b0a
authored
May 16, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made Knight class
parent
1cce88ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
Knight.java
src/pieces/Knight.java
+24
-0
No files found.
src/pieces/Knight.java
0 → 100644
View file @
b0e19b0a
package
pieces
;
import
game.Square
;
import
java.util.ArrayList
;
public
class
Knight
extends
Piece
{
public
Knight
(
String
ID
,
String
imagePath
,
String
color
)
{
setPieceId
(
ID
);
setImage
(
imagePath
);
setPieceColor
(
color
);
}
public
ArrayList
<
Square
>
move
(
Square
[][]
boardSquares
,
int
x
,
int
y
)
{
possibleSquares
.
clear
();
int
posx
[]
=
{
x
+
1
,
x
+
1
,
x
+
2
,
x
+
2
,
x
-
1
,
x
-
1
,
x
-
2
,
x
-
2
};
int
posy
[]
=
{
y
-
2
,
y
+
2
,
y
-
1
,
y
+
1
,
y
-
2
,
y
+
2
,
y
-
1
,
y
+
1
};
for
(
int
i
=
0
;
i
<
8
;
i
++)
if
((
posx
[
i
]
>=
0
&&
posx
[
i
]
<
8
&&
posy
[
i
]
>=
0
&&
posy
[
i
]
<
8
))
if
((
boardSquares
[
posx
[
i
]][
posy
[
i
]].
getPiece
()
==
null
||
boardSquares
[
posx
[
i
]][
posy
[
i
]].
getPiece
().
getPieceColor
()
!=
this
.
getPieceColor
()))
{
possibleSquares
.
add
(
boardSquares
[
posx
[
i
]][
posy
[
i
]]);
}
return
possibleSquares
;
}
}
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