Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
agile-java
/
ChessAndroid
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
63f13924
authored
Jun 01, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Left isMovable() method only for parent Piece class
parent
a932bb0c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
4 additions
and
34 deletions
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Bishop.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/King.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Knight.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Pawn.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Piece.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Queen.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Rook.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Bishop.java
View file @
63f13924
...
...
@@ -13,8 +13,4 @@ public class Bishop extends Piece {
this
.
color
=
color
;
}
@Override
public
boolean
isMovable
(
Position
from
,
Position
to
)
{
return
false
;
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/King.java
View file @
63f13924
package
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
;
import
com.example.paktalin.agilejava_exercises.Position
;
import
com.example.paktalin.agilejava_exercises.moves.KingMoveStrategy
;
/**
...
...
@@ -14,9 +13,4 @@ public class King extends Piece {
moveStrategy
=
new
KingMoveStrategy
();
this
.
color
=
color
;
}
@Override
public
boolean
isMovable
(
Position
from
,
Position
to
)
{
return
(
new
KingMoveStrategy
()).
isMovable
(
from
,
to
);
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Knight.java
View file @
63f13924
...
...
@@ -13,8 +13,4 @@ public class Knight extends Piece {
this
.
color
=
color
;
}
@Override
public
boolean
isMovable
(
Position
from
,
Position
to
)
{
return
false
;
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Pawn.java
View file @
63f13924
...
...
@@ -26,11 +26,6 @@ public class Pawn extends Piece {
}
}
@Override
public
boolean
isMovable
(
Position
from
,
Position
to
)
{
return
false
;
}
private
static
boolean
pawnsOnSameColumn
(
Piece
currentPiece
,
Piece
piece
)
{
return
piece
.
getPosition
().
getColumn
()
==
currentPiece
.
getPosition
().
getColumn
()
&&
piece
.
getPosition
().
getRow
()
!=
currentPiece
.
getPosition
().
getRow
()
&&
...
...
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Piece.java
View file @
63f13924
...
...
@@ -19,7 +19,7 @@ public abstract class Piece implements Comparable<Piece> {
Color
color
;
double
strength
;
Position
position
;
private
Position
position
;
MoveStrategy
moveStrategy
;
char
representation
;
...
...
@@ -50,7 +50,9 @@ public abstract class Piece implements Comparable<Piece> {
return
0
;
}
public
abstract
boolean
isMovable
(
Position
from
,
Position
to
);
public
boolean
isMovable
(
Position
from
,
Position
to
){
return
moveStrategy
.
isMovable
(
from
,
to
);
}
public
double
getStrength
()
{
return
this
.
strength
;
...
...
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Queen.java
View file @
63f13924
...
...
@@ -16,10 +16,4 @@ public class Queen extends Piece {
moveStrategy
=
new
QueenMoveStrategy
();
this
.
color
=
color
;
}
@Override
public
boolean
isMovable
(
Position
from
,
Position
to
)
{
return
(
new
QueenMoveStrategy
()).
isMovable
(
from
,
to
);
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Rook.java
View file @
63f13924
package
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
;
import
com.example.paktalin.agilejava_exercises.Position
;
/**
* Created by Paktalin on 01/06/2018.
*/
...
...
@@ -13,9 +11,4 @@ public class Rook extends Piece{
representation
=
'r'
;
this
.
color
=
color
;
}
@Override
public
boolean
isMovable
(
Position
from
,
Position
to
)
{
return
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