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
1cce88ac
Commit
1cce88ac
authored
May 16, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made Bishop class
parent
e66ae3fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
Bishop.java
src/pieces/Bishop.java
+83
-0
No files found.
src/pieces/Bishop.java
0 → 100644
View file @
1cce88ac
package
pieces
;
import
game.Square
;
import
java.util.ArrayList
;
public
class
Bishop
extends
Piece
{
public
Bishop
(
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
,
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
;
}
}
\ No newline at end of file
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