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
2a341b7f
authored
May 23, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lesson 2 is done
parent
a46fdc5e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
9 deletions
app/src/main/java/com/example/paktalin/agilejava_exercises/Board.java
app/src/main/java/com/example/paktalin/agilejava_exercises/Pawn.java → app/src/main/java/com/example/paktalin/agilejava_exercises/pieces/Pawn.java
app/src/test/java/com/example/paktalin/agilejava_exercises/AllTests.java
app/src/test/java/com/example/paktalin/agilejava_exercises/BoardTest.java
app/src/test/java/com/example/paktalin/agilejava_exercises/PawnTest.java → app/src/test/java/com/example/paktalin/agilejava_exercises/pieces/PawnTest.java
app/src/main/java/com/example/paktalin/agilejava_exercises/Board.java
0 → 100644
View file @
2a341b7f
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
com.example.paktalin.agilejava_exercises.pieces.Pawn
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by Paktalin on 23/05/2018.
*/
class
Board
{
private
List
<
Pawn
>
pawns
=
new
ArrayList
<>();
int
getNumberOfPieces
()
{
return
pawns
.
size
();
}
void
addPawn
(
Pawn
pawn
)
{
pawns
.
add
(
pawn
);
}
Pawn
getPawn
(
int
index
)
{
return
pawns
.
get
(
index
);
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/Pawn.java
→
app/src/main/java/com/example/paktalin/agilejava_exercises/
pieces/
Pawn.java
View file @
2a341b7f
package
com
.
example
.
paktalin
.
agilejava_exercises
;
package
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
;
/**
* Created by Paktalin on 23/05/2018.
*/
class
Pawn
{
private
String
color
=
"white"
;
public
class
Pawn
{
public
static
String
COLOR_WHITE
=
"white"
;
public
static
String
COLOR_BLACK
=
"black"
;
Pawn
(
final
String
color
)
{
private
String
color
;
public
Pawn
()
{
color
=
"white"
;
}
public
Pawn
(
final
String
color
)
{
this
.
color
=
color
;
}
String
getColor
()
{
public
String
getColor
()
{
return
color
;
}
}
app/src/test/java/com/example/paktalin/agilejava_exercises/AllTests.java
0 → 100644
View file @
2a341b7f
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
com.example.paktalin.agilejava_exercises.pieces.PawnTest
;
import
junit.framework.TestSuite
;
/**
* Created by Paktalin on 23/05/2018.
*/
public
class
AllTests
extends
TestSuite
{
public
static
TestSuite
suite
()
{
TestSuite
suite
=
new
TestSuite
();
suite
.
addTestSuite
(
PawnTest
.
class
);
suite
.
addTestSuite
(
BoardTest
.
class
);
return
suite
;
}
}
app/src/test/java/com/example/paktalin/agilejava_exercises/BoardTest.java
0 → 100644
View file @
2a341b7f
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
com.example.paktalin.agilejava_exercises.pieces.Pawn
;
import
junit.framework.TestCase
;
/**
* Created by Paktalin on 23/05/2018.
*/
public
class
BoardTest
extends
TestCase
{
private
Board
board
;
public
void
setUp
()
{
board
=
new
Board
();
}
public
void
testBoard
()
{
assertEquals
(
0
,
board
.
getNumberOfPieces
());
}
public
void
testNumberOfPieces
()
{
Pawn
pawn
=
new
Pawn
(
Pawn
.
COLOR_BLACK
);
board
.
addPawn
(
pawn
);
assertEquals
(
1
,
board
.
getNumberOfPieces
());
assertEquals
(
"black"
,
board
.
getPawn
(
0
).
getColor
());
}
}
app/src/test/java/com/example/paktalin/agilejava_exercises/PawnTest.java
→
app/src/test/java/com/example/paktalin/agilejava_exercises/
pieces/
PawnTest.java
View file @
2a341b7f
package
com
.
example
.
paktalin
.
agilejava_exercises
;
package
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
;
import
junit.framework.TestCase
;
import
static
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
.
Pawn
.
COLOR_BLACK
;
import
static
com
.
example
.
paktalin
.
agilejava_exercises
.
pieces
.
Pawn
.
COLOR_WHITE
;
/**
* Created by Paktalin on 23/05/2018.
*/
...
...
@@ -9,13 +12,15 @@ import junit.framework.TestCase;
public
class
PawnTest
extends
TestCase
{
public
void
testCreate
()
{
String
COLOR_WHITE
=
"white"
;
String
COLOR_BLACK
=
"black"
;
Pawn
pawn
=
new
Pawn
(
COLOR_WHITE
);
assertEquals
(
"white"
,
pawn
.
getColor
());
Pawn
pawn2
=
new
Pawn
(
COLOR_BLACK
);
assertEquals
(
"black"
,
pawn2
.
getColor
());
}
public
void
testConstructor
()
{
Pawn
pawn
=
new
Pawn
();
assertEquals
(
"white"
,
pawn
.
getColor
());
}
}
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