-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathChessApplication.java
More file actions
34 lines (24 loc) · 1.06 KB
/
Copy pathChessApplication.java
File metadata and controls
34 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.chess;
import com.chess.interfaces.IChessApplication;
import com.chessBoard.interfaces.IChessBoard;
import com.chessPiece.interfaces.IChessPiece;
import com.chessPiece.interfaces.IChessPieceFactory;
import com.coordinates.Coordinates;
import com.enums.ChessPieceType;
public class ChessApplication implements IChessApplication {
private IChessBoard chessBoard;
private IChessPieceFactory chessPieceFactory;
@Override
public boolean makeAMove(Coordinates startCoordinates, Coordinates endCoordinates) {
if (!this.isValidMove(startCoordinates, endCoordinates)) {
return false;
}
IChessPiece chessPiece = this.chessBoard.getChessPieceAtCoordinate(startCoordinates);
this.chessBoard.setChessPieceAtCoordinate(startCoordinates, this.chessPieceFactory.createChessPiece(ChessPieceType.NONE, null));
this.chessBoard.setChessPieceAtCoordinate(endCoordinates, chessPiece);
return true;
}
private boolean isValidMove(Coordinates startCoordinates, Coordinates endCoordinates) {
return this.isValidMove(startCoordinates, endCoordinates);
}
}