-
Notifications
You must be signed in to change notification settings - Fork 461
Expand file tree
/
Copy pathChessController.java
More file actions
40 lines (32 loc) · 1.19 KB
/
ChessController.java
File metadata and controls
40 lines (32 loc) · 1.19 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
35
36
37
38
39
40
package chess.controller;
import chess.domain.board.ChessBoard;
import chess.domain.board.InitBoardGenerator;
import chess.domain.piece.Column;
import chess.domain.piece.Row;
import chess.view.InputView;
import chess.view.OutputVIew;
import java.util.Map.Entry;
public class ChessController {
private ChessBoard chessBoard;
public void run() {
chessBoard = new ChessBoard(InitBoardGenerator.initChessBoard());
OutputVIew.printChessBoard(chessBoard);
while (!chessBoard.isEnd()) {
moveWhite();
OutputVIew.printChessBoard(chessBoard);
if (chessBoard.isEnd()) break;
moveBlack();
OutputVIew.printChessBoard(chessBoard);
}
}
private void moveWhite() {
Entry<Column, Row> currentPosition = InputView.choiceWhitePiece();
Entry<Column, Row> destination = InputView.choiceDestination();
chessBoard.moveWhite(currentPosition, destination);
}
private void moveBlack() {
Entry<Column, Row> currentPosition = InputView.choiceBlackPiece();
Entry<Column, Row> destination = InputView.choiceDestination();
chessBoard.moveBlack(currentPosition, destination);
}
}