Commit 2af1b9c5 by Paktalin

6.1 complete

parent 502537f3
......@@ -31,9 +31,11 @@ class Board {
void placePiece(Piece piece, String position) {
layout.placePiece(piece, position);
}
Piece getPieceAtPosition(String position) {
return layout.getPieceAtPosition(position);
}
String print() {
return layout.print();
}
......@@ -41,6 +43,7 @@ class Board {
void addToCollection(Piece piece) {
getSide(piece.getColor()).addPiece(piece);
}
private Side getSide(Piece.Color color){
if (color == White)
return whiteSide;
......
......@@ -23,45 +23,38 @@ public class Piece implements Comparable<Piece>{
this.type = type;
}
public Color getColor() {
return color;
}
Type getType() {
return type;
}
char getRepresentation() {
char representation = 0;
if (type == Type.King)
representation = 'k';
if (type == Type.Queen)
representation = 'q';
if (type == Type.Pawn)
representation = 'p';
if (type == Type.Rook)
representation = 'r';
if (type == Type.Bishop)
representation = 'b';
if (type == Type.Knight)
representation = 'n';
char representation = getRepresentationLetter();
if (this.isBlack())
return Character.toUpperCase(representation);
return representation;
}
private char getRepresentationLetter() {
switch (this.type) {
case Knight: return 'n';
case King: return 'k';
case Queen: return 'q';
case Rook: return 'r';
case Bishop: return 'b';
default: return 'p';
}
}
void setStrength(double strength) {
this.strength = strength;
}
void setStrength() {
if (type == Type.Queen)
strength = 9;
if (type == Type.Rook)
strength = 5;
if (type == Type.Bishop)
strength = 3;
if (type == Type.Knight)
strength = 2.5;
if (type == Type.King)
strength = 0.0;
strength = calculateStrength();
}
private double calculateStrength() {
switch (this.type) {
case Queen: return 9;
case Rook: return 5;
case Bishop: return 3;
case Knight: return 2.5;
default: return 0;
}
}
@Override
......@@ -73,13 +66,15 @@ public class Piece implements Comparable<Piece>{
return 0;
}
void setStrength(double strength) {
this.strength = strength;
}
double getStrength() {
return strength;
}
public Color getColor() {
return color;
}
Type getType() {
return type;
}
boolean isColor(Color color) {
return this.color == color;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment