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
0462ecfd
Commit
0462ecfd
authored
May 16, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made Queen class
parent
b0e19b0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
132 additions
and
0 deletions
+132
-0
King.java
src/pieces/King.java
+4
-0
Queen.java
src/pieces/Queen.java
+128
-0
No files found.
src/pieces/King.java
0 → 100644
View file @
0462ecfd
package
pieces
;
public
class
King
{
}
src/pieces/Queen.java
0 → 100644
View file @
0462ecfd
package
pieces
;
import
game.Square
;
import
java.util.ArrayList
;
public
class
Queen
extends
Piece
{
public
Queen
(
String
ID
,
String
imagePath
,
String
color
){
setPieceId
(
ID
);
setImage
(
imagePath
);
setPieceColor
(
color
);
}
public
ArrayList
<
Square
>
move
(
Square
[][]
boardSquares
,
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
tempx
=
x
-
1
;
while
(
tempx
>=
0
)
{
if
(
boardSquares
[
tempx
][
y
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
tempx
][
y
]);
else
if
(
boardSquares
[
tempx
][
y
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
tempx
][
y
]);
break
;
}
tempx
--;
}
tempx
=
x
+
1
;
while
(
tempx
<
8
)
{
if
(
boardSquares
[
tempx
][
y
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
tempx
][
y
]);
else
if
(
boardSquares
[
tempx
][
y
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
tempx
][
y
]);
break
;
}
tempx
++;
}
int
tempy
=
y
-
1
;
while
(
tempy
>=
0
)
{
if
(
boardSquares
[
x
][
tempy
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
x
][
tempy
]);
else
if
(
boardSquares
[
x
][
tempy
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
x
][
tempy
]);
break
;
}
tempy
--;
}
tempy
=
y
+
1
;
while
(
tempy
<
8
)
{
if
(
boardSquares
[
x
][
tempy
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
x
][
tempy
]);
else
if
(
boardSquares
[
x
][
tempy
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
x
][
tempy
]);
break
;
}
tempy
++;
}
tempx
=
x
+
1
;
tempy
=
y
-
1
;
while
(
tempx
<
8
&&
tempy
>=
0
)
{
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
else
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
break
;
}
tempx
++;
tempy
--;
}
tempx
=
x
-
1
;
tempy
=
y
+
1
;
while
(
tempx
>=
0
&&
tempy
<
8
)
{
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
else
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
break
;
}
tempx
--;
tempy
++;
}
tempx
=
x
-
1
;
tempy
=
y
-
1
;
while
(
tempx
>=
0
&&
tempy
>=
0
)
{
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
else
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
break
;
}
tempx
--;
tempy
--;
}
tempx
=
x
+
1
;
tempy
=
y
+
1
;
while
(
tempx
<
8
&&
tempy
<
8
)
{
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
()
==
null
)
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
else
if
(
boardSquares
[
tempx
][
tempy
].
getPiece
().
getPieceColor
()
==
this
.
getPieceColor
())
break
;
else
{
possibleSquares
.
add
(
boardSquares
[
tempx
][
tempy
]);
break
;
}
tempx
++;
tempy
++;
}
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