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
0729bc5d
authored
Jun 01, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed Type field
parent
c47028e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
44 deletions
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Piece.java
app/src/test/java/com/example/paktalin/agilejava_exercises/BoardTest.java
app/src/test/java/com/example/paktalin/agilejava_exercises/PieceTest.java
app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Piece.java
View file @
0729bc5d
...
...
@@ -25,41 +25,6 @@ public abstract class Piece implements Comparable<Piece> {
Piece
()
{}
public
enum
Type
{
Pawn
(
1
,
'p'
),
Knight
(
2.5
,
'n'
),
Rook
(
5
,
'r'
),
Bishop
(
3
,
'b'
),
Queen
(
9
,
'q'
,
new
QueenMoveStrategy
());
private
double
strength
;
private
char
representation
;
private
MoveStrategy
moveStrategy
;
Type
(
double
strength
,
char
representation
,
MoveStrategy
moveStrategy
)
{
this
.
strength
=
strength
;
this
.
representation
=
representation
;
this
.
moveStrategy
=
moveStrategy
;
}
Type
(
double
strength
,
char
representation
)
{
this
.
strength
=
strength
;
this
.
representation
=
representation
;
}
public
char
getRepresentation
()
{
return
representation
;
}
public
double
getStrength
()
{
return
strength
;
}
public
MoveStrategy
getMoveStrategy
()
{
return
moveStrategy
;
}
}
public
void
setPosition
(
Position
position
)
{
this
.
position
=
position
;
}
...
...
app/src/test/java/com/example/paktalin/agilejava_exercises/BoardTest.java
View file @
0729bc5d
...
...
@@ -13,7 +13,6 @@ import junit.framework.TestCase;
import
java.util.List
;
import
static
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
.
Piece
.
Color
.*;
import
static
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
.
Piece
.
Type
.*;
/**
* Created by Paktalin on 23/05/2018.
...
...
app/src/test/java/com/example/paktalin/agilejava_exercises/PieceTest.java
View file @
0729bc5d
...
...
@@ -10,7 +10,6 @@ import com.example.paktalin.agilejava_exercises.pieces.Rook;
import
junit.framework.TestCase
;
import
static
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
.
Piece
.
Type
.*;
import
static
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
.
Piece
.
Color
.*;
/**
...
...
@@ -20,15 +19,15 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.*;
public
class
PieceTest
extends
TestCase
{
public
void
testCreate
()
{
verifyCreation
(
new
Pawn
(
White
),
new
Pawn
(
Black
),
Pawn
,
'p'
);
//verifyCreation(new King(White), new King(Black), King
, 'k');
verifyCreation
(
new
Bishop
(
White
),
new
Bishop
(
Black
),
Bishop
,
'b'
);
verifyCreation
(
new
Rook
(
White
),
new
Rook
(
Black
),
Rook
,
'r'
);
verifyCreation
(
new
Knight
(
White
),
new
Knight
(
Black
),
Knight
,
'n'
);
verifyCreation
(
new
Queen
(
White
),
new
Queen
(
Black
),
Queen
,
'q'
);
verifyCreation
(
new
Pawn
(
White
),
new
Pawn
(
Black
),
'p'
);
verifyCreation
(
new
King
(
White
),
new
King
(
Black
)
,
'k'
);
verifyCreation
(
new
Bishop
(
White
),
new
Bishop
(
Black
),
'b'
);
verifyCreation
(
new
Rook
(
White
),
new
Rook
(
Black
),
'r'
);
verifyCreation
(
new
Knight
(
White
),
new
Knight
(
Black
),
'n'
);
verifyCreation
(
new
Queen
(
White
),
new
Queen
(
Black
),
'q'
);
}
private
void
verifyCreation
(
Piece
whitePiece
,
Piece
blackPiece
,
Piece
.
Type
type
,
char
representation
)
{
private
void
verifyCreation
(
Piece
whitePiece
,
Piece
blackPiece
,
char
representation
)
{
assertTrue
(
whitePiece
.
isWhite
());
assertEquals
(
representation
,
whitePiece
.
getRepresentation
());
...
...
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