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
e27c92e5
authored
May 27, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Substituted interface with one class
parent
1263e172
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
107 deletions
app/src/main/java/com/example/paktalin/agilejava_exercises/BlackSide.java
app/src/main/java/com/example/paktalin/agilejava_exercises/Board.java
app/src/main/java/com/example/paktalin/agilejava_exercises/Side.java
app/src/main/java/com/example/paktalin/agilejava_exercises/WhiteSide.java
app/src/main/java/com/example/paktalin/agilejava_exercises/BlackSide.java
deleted
100644 → 0
View file @
1263e172
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Created by Paktalin on 26/05/2018.
*/
class
BlackSide
implements
Side
{
private
List
<
Piece
>
pieces
=
new
ArrayList
<>();
@Override
public
List
<
Piece
>
getPieces
()
{
return
pieces
;
}
@Override
public
double
getStrength
()
{
double
strength
=
0.0
;
for
(
Piece
piece
:
pieces
)
strength
+=
piece
.
getStrength
();
return
strength
;
}
@Override
public
int
getPiecesCount
()
{
return
pieces
.
size
();
}
@Override
public
int
getPiecesCount
(
Piece
.
Type
type
)
{
int
count
=
0
;
for
(
Piece
piece
:
pieces
)
if
(
piece
.
isType
(
type
))
count
++;
return
count
;
}
@Override
public
void
addPiece
(
Piece
piece
)
{
pieces
.
add
(
piece
);
Collections
.
sort
(
pieces
);
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/Board.java
View file @
e27c92e5
...
...
@@ -15,8 +15,8 @@ class Board {
private
Piece
[][]
pieces
=
new
Piece
[
ROW_COUNT
][
COLUMN_COUNT
];
private
WhiteSide
whiteSide
=
new
White
Side
();
private
BlackSide
blackSide
=
new
Black
Side
();
private
Side
whiteSide
=
new
Side
();
private
Side
blackSide
=
new
Side
();
private
Board
()
{}
...
...
app/src/main/java/com/example/paktalin/agilejava_exercises/Side.java
View file @
e27c92e5
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Created by Paktalin on 2
6
/05/2018.
* Created by Paktalin on 2
7
/05/2018.
*/
interface
Side
{
class
Side
{
private
List
<
Piece
>
pieces
=
new
ArrayList
<>();
List
<
Piece
>
getPieces
();
double
getStrength
();
int
getPiecesCount
();
int
getPiecesCount
(
Piece
.
Type
type
);
void
addPiece
(
Piece
piece
);
public
List
<
Piece
>
getPieces
()
{
return
pieces
;
}
public
double
getStrength
()
{
double
strength
=
0.0
;
for
(
Piece
piece
:
pieces
)
strength
+=
piece
.
getStrength
();
return
strength
;
}
public
int
getPiecesCount
()
{
return
pieces
.
size
();
}
public
int
getPiecesCount
(
Piece
.
Type
type
)
{
int
count
=
0
;
for
(
Piece
piece
:
pieces
)
if
(
piece
.
isType
(
type
))
count
++;
return
count
;
}
public
void
addPiece
(
Piece
piece
)
{
pieces
.
add
(
piece
);
Collections
.
sort
(
pieces
);
}
}
app/src/main/java/com/example/paktalin/agilejava_exercises/WhiteSide.java
deleted
100644 → 0
View file @
1263e172
package
com
.
example
.
paktalin
.
agilejava_exercises
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Created by Paktalin on 26/05/2018.
*/
public
class
WhiteSide
implements
Side
{
private
List
<
Piece
>
pieces
=
new
ArrayList
<>();
@Override
public
List
<
Piece
>
getPieces
()
{
return
pieces
;
}
@Override
public
double
getStrength
()
{
double
strength
=
0.0
;
for
(
Piece
piece
:
pieces
)
strength
+=
piece
.
getStrength
();
return
strength
;
}
@Override
public
int
getPiecesCount
()
{
return
pieces
.
size
();
}
@Override
public
int
getPiecesCount
(
Piece
.
Type
type
)
{
int
count
=
0
;
for
(
Piece
piece
:
pieces
)
if
(
piece
.
isType
(
type
))
count
++;
return
count
;
}
@Override
public
void
addPiece
(
Piece
piece
)
{
pieces
.
add
(
piece
);
Collections
.
sort
(
pieces
);
}
}
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