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
6e2c73e4
Commit
6e2c73e4
authored
May 16, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made King class 'first functions'
parent
0462ecfd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletion
+43
-1
King.java
src/pieces/King.java
+43
-1
No files found.
src/pieces/King.java
View file @
6e2c73e4
package
pieces
;
package
pieces
;
public
class
King
{
import
game.Square
;
import
java.util.ArrayList
;
public
class
King
extends
Piece
{
private
int
x
,
y
;
public
King
(
String
ID
,
String
imagePath
,
String
color
,
int
x
,
int
y
)
{
this
.
x
=
x
;
this
.
y
=
y
;
setPieceId
(
ID
);
setImage
(
imagePath
);
setPieceColor
(
color
);
}
public
void
setx
(
int
x
)
{
this
.
x
=
x
;
}
public
void
sety
(
int
y
)
{
this
.
y
=
y
;
}
public
int
getx
()
{
return
x
;
}
public
int
gety
()
{
return
y
;
}
public
ArrayList
<
Square
>
move
(
Square
state
[][],
int
x
,
int
y
){
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
possibleSquares
.
clear
();
int
posx
[]={
x
,
x
,
x
+
1
,
x
+
1
,
x
+
1
,
x
-
1
,
x
-
1
,
x
-
1
};
int
posy
[]={
y
-
1
,
y
+
1
,
y
-
1
,
y
,
y
+
1
,
y
-
1
,
y
,
y
+
1
};
for
(
int
i
=
0
;
i
<
8
;
i
++)
if
((
posx
[
i
]>=
0
&&
posx
[
i
]<
8
&&
posy
[
i
]>=
0
&&
posy
[
i
]<
8
))
if
((
state
[
posx
[
i
]][
posy
[
i
]].
getPiece
()==
null
||
!
state
[
posx
[
i
]][
posy
[
i
]].
getPiece
().
getPieceColor
().
equals
(
this
.
getPieceColor
())))
possibleSquares
.
add
(
state
[
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