-
Notifications
You must be signed in to change notification settings - Fork 166
[๐ ์ฌ์ดํด1 - ๋ฏธ์ (๋ณด๋ ์ด๊ธฐํ + ๊ธฐ๋ฌผ ์ด๋)] ์์ฌ ๋ฏธ์ ์ ์ถํฉ๋๋ค. #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yeo-li
wants to merge
34
commits into
woowacourse:yeo-li
Choose a base branch
from
yeo-li:step1
base: yeo-li
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1b6e5a4
feat: ๊ฐ ํ๋ ์ด์ด ์งํ ์
๋ ฅ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech 7e578e4
test: Board ์ด๊ธฐํ ํ
์คํธ ์ฝ๋ ๊ตฌํ
win9-tech 903920f
test: Position ํ
์คํธ ์ฝ๋ ๊ตฌํ
win9-tech 9be4c87
feat: Board ์ด๊ธฐํ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech d96f899
feat: ์ฅ๊ธฐํ ์ํ ์ถ๋ ฅ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech a9010a4
refactor: Board ์ด๊ธฐ ๋ฐฐ์น ๋ก์ง ์ค๋ณต ์ ๊ฑฐ
win9-tech 08e53e3
feat: ์์ง์ผ ๊ธฐ๋ฌผ ์ขํ ์
๋ ฅ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech 7b91ab8
feat: ๋ชฉ์ ์ง ์ขํ ์
๋ ฅ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech 6ca130e
feat: ํด์ ์์คํ
๋ฐ ์ฅ๊ธฐ ์งํ์ํ ์ถ๋ ฅ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech 1f698a8
test: ๊ธฐ๋ฌผ ์ด๋ ํ
์คํธ ์ฝ๋ ๊ตฌํ
win9-tech 0b0a46c
feat: ๊ธฐ๋ฌผ ์ด๋ ๊ธฐ๋ฅ ๊ตฌํ
win9-tech 668aced
feat: ํด ๊ด๋ฆฌ๋ฅผ ์ํ Turn ๋๋ฉ์ธ ๊ฐ์ฒด ์ถ๊ฐ
win9-tech 8542552
fix: KingTest์์ Horse๋ก ์์ฑํ๋ ๋ฒ๊ทธ ์์
win9-tech 4c158e8
refactor: ๊ธฐ๋ฌผ ๋ฐฐ์น ๋ก์ง์ ํ๋์ฝ๋ฉ์ ์์ ๊ธฐ๋ฐ์ผ๋ก ๊ฐ์
win9-tech 4895748
refactor: movePiece ๋ด๋ถ ๋ก์ง์ ๋ฉ์๋๋ก ๋ถ๋ฆฌ
win9-tech 50f7d45
refactor: MovementStrategy ํจํด ์ ์ฉ ๋ฐ ์๋ฌ ๋ฉ์์ง ์์ํ
win9-tech b797150
test: ๊ธฐ๋ฌผ ํ
์คํธ ์ฝ๋ ์์
win9-tech 46319b0
test: ๊ธฐ๋ฌผ ์ด๋ ํ
์คํธ if ๋ถ๊ธฐ ์ ๊ฑฐ ๋ฐ ์ ํจ/๋ฌดํจ ์ผ์ด์ค ๋ถ๋ฆฌ
win9-tech ccf486f
refactor: ๊ธฐ๋ฌผ ์ด๋ ์ ๋ต ๋ถ๋ฆฌ ๋ฐ ๊ฒฝ๋ก ๊ณ์ฐ ๊ตฌ์กฐ ๊ฐ์
win9-tech 3fa6172
docs: README.md ์
๋ฐ์ดํธ
win9-tech d9dd2fa
refactor: Position ์บ์ฑ ์ ์ฉ
win9-tech 6b196a3
test: Position canMove ํ
์คํธ ์ฝ๋ ๊ตฌํ
win9-tech cfe69c0
refactor: ERROR ๋ฉ์์ง ์์์ฒ๋ฆฌ
win9-tech 88cfd05
refactor: findRoute ๋ฉ์๋ movementStrategy.findRoute()๋ก ๋ณ๊ฒฝ
yeo-li 909b7c5
fix: findRoute() targetPosition์ด List<Position>์ ๋ง์ง๋ง์ธ์ง ํ์ธํ๋๋ก ๋ณ๊ฒฝ
yeo-li cb5d39d
feat(input): ์ขํ ์
๋ ฅ ํ์ฑ ๋ก์ง ์ถ๊ฐ ๋ฐ ์ ํจ์ฑ ๊ฒ์ฆ ๊ฐํ
yeo-li 6694397
fix: Piece.checkRoute() ์๋ฌ ๋ฉ์ธ์ง ์์
yeo-li e4bb045
refactor: Board ๊ฒ์ ๋น์ง๋์ค ๋ก์ง ์ ๊ฑฐ ๋ฐ Game์ผ๋ก ์ด๋
yeo-li bd6c89a
refactor: BoardFactory ๋์
๋ฐ Game/Board ํ
์คํธ ์์ฑ ๋ฐฉ์ ์ ๋ฆฌ
yeo-li bfc79bc
refactor: Elephant ์์ฑ์ ์์กด์ฑ ์ฃผ์
์ผ๋ก ํต์ผ
yeo-li 9b17899
refactor: BoardSpec ๋์
์ผ๋ก ๋ณด๋ ๋ฒ์์ ์์ ํด ํ๋์ฝ๋ฉ ์ ๊ฑฐ
yeo-li 0cf6e2e
refactor: Position CACHE key-value ๊ตฌ์กฐ ๋ณ๊ฒฝ
yeo-li 3f4be1b
refactor: Side.NONE ์ ๊ฑฐ ๋ฐ ๊ฒ์ ์ข
๋ฃ ์กฐ๊ฑด(isGameEnd) ๋์
yeo-li 8569773
style: ๊ณต๋ฐฑ ๋ฐ ๋ฉ์๋ ์์ ์ ๋ฆฌ
yeo-li File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,73 @@ | ||
| # java-janggi | ||
|
|
||
| ์ฅ๊ธฐ ๋ฏธ์ ์ ์ฅ์ | ||
|
|
||
| # ๊ธฐ๋ฅ | ||
|
|
||
| ## 1-1 ์๊ตฌ์ฌํญ | ||
| - [x] ๊ฐ ํ๋ ์ด์ด ์งํ ์ ๋ ฅ ๊ธฐ๋ฅ | ||
| - [x] ์ฅ๊ธฐํ ์ด๊ธฐํ ๊ธฐ๋ฅ | ||
| - [x] ์ฅ๊ธฐํ ์ํ ์ถ๋ ฅ ๊ธฐ๋ฅ | ||
|
|
||
| ## 1-2 ์๊ตฌ์ฌํญ | ||
| - [x] ์ด๋ํ ๊ธฐ๋ฌผ ์์น ์ขํ ์ ๋ ฅ ๊ธฐ๋ฅ | ||
| - [x] ์ด๋ํ ๋ชฉ์ ์ง ์ขํ ์ ๋ ฅ ๊ธฐ๋ฅ | ||
| - [x] ํด์ ์์คํ ๊ธฐ๋ฅ | ||
| - [x] ์ฅ๊ธฐ ์งํ ์ํ ์ถ๋ ฅ ๊ธฐ๋ฅ | ||
| - [x] ๊ธฐ๋ฌผ ์ด๋ ๊ธฐ๋ฅ | ||
|
|
||
| ## โ ๏ธ ๊ธฐ๋ฅ ์์ธ ์ฌํญ | ||
|
|
||
| ### ์ ๋ ฅ ๊ฒ์ฆ | ||
| - ํฌ์ง ์ ํ: 1~4 ๋ฒ์ ์ธ ์ ๋ ฅ ์ ์์ธ | ||
| - ์ขํ ๋ฒ์: x(1~9), y(1~10) ๋ฒ์ ์ธ ์ ๋ ฅ ์ ์์ธ | ||
|
|
||
| ### ๊ธฐ๋ฌผ ์ ํ ๊ฒ์ฆ | ||
| - ์ ํํ ์์น์ ๊ธฐ๋ฌผ์ด ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ ์์ธ | ||
| - ์ ํํ ๊ธฐ๋ฌผ์ด ์๊ตฐ ๊ธฐ๋ฌผ์ด ์๋ ๊ฒฝ์ฐ ์์ธ | ||
|
|
||
| ### ์ด๋ ๊ท์น ๊ฒ์ฆ | ||
| - ๋ชฉ์ ์ง๊ฐ ๊ธฐ๋ฌผ์ ์ด๋ ๊ท์น์ ๋ง์ง ์์ ๊ฒฝ์ฐ ์์ธ | ||
| - ๋ชฉ์ ์ง์ ์๊ตฐ ๊ธฐ๋ฌผ์ด ์กด์ฌํ ๊ฒฝ์ฐ ์์ธ | ||
| - ์ด๋ ๊ฒฝ๋ก์ ๊ธฐ๋ฌผ์ด ์กด์ฌํ ๊ฒฝ์ฐ ์์ธ (ํฌ ์ ์ธ) | ||
|
|
||
| ### ํฌ ๊ท์น ๊ฒ์ฆ | ||
| - ์ด๋ ๊ฒฝ๋ก์ ํฌ๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ ์์ธ | ||
| - ์ด๋ ๊ฒฝ๋ก์ ๊ธฐ๋ฌผ์ด ์ ํํ 1๊ฐ๊ฐ ์๋ ๊ฒฝ์ฐ ์์ธ | ||
| - ํฌ๋ก ํฌ๋ฅผ ์ก์ผ๋ ค ํ ๊ฒฝ์ฐ ์์ธ | ||
|
|
||
| --- | ||
|
|
||
| ## ๐ ํ๋ก์ ํธ ๊ตฌ์กฐ | ||
|
|
||
| ``` | ||
| src/main/java | ||
| โโโ Main.java | ||
| โโโ controller | ||
| โ โโโ JanggiController.java | ||
| โโโ domain | ||
| โ โโโ Board.java | ||
| โ โโโ Direction.java | ||
| โ โโโ Formation.java | ||
| โ โโโ Position.java | ||
| โ โโโ Side.java | ||
| โ โโโ Turn.java | ||
| โ โโโ piece | ||
| โ โ โโโ Piece.java | ||
| โ โ โโโ PieceType.java | ||
| โ โ โโโ King.java | ||
| โ โ โโโ Guard.java | ||
| โ โ โโโ Horse.java | ||
| โ โ โโโ Elephant.java | ||
| โ โ โโโ Chariot.java | ||
| โ โ โโโ Cannon.java | ||
| โ โ โโโ Soldier.java | ||
| โ โ โโโ Empty.java | ||
| โ โโโ strategy | ||
| โ โโโ MovementStrategy.java | ||
| โ โโโ PathMovement.java | ||
| โ โโโ LinearMovement.java | ||
| โโโ view | ||
| โโโ InputView.java | ||
| โโโ OutputView.java | ||
| ``` |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import controller.JanggiController; | ||
| import view.InputView; | ||
| import view.OutputView; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| JanggiController janggiController = new JanggiController(new InputView(), new OutputView()); | ||
| janggiController.run(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package constant; | ||
|
|
||
| import domain.Side; | ||
|
|
||
| public class BoardSpec { | ||
|
|
||
| public static final int MIN_X = 1; | ||
| public static final int MAX_X = 9; | ||
| public static final int MIN_Y = 1; | ||
| public static final int MAX_Y = 10; | ||
|
|
||
| public static final Side DEFAULT_STARTING_SIDE = Side.CHO; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| package controller; | ||
|
|
||
| import domain.Board; | ||
| import domain.BoardFactory; | ||
| import domain.Formation; | ||
| import domain.Game; | ||
| import domain.Position; | ||
| import domain.Side; | ||
| import util.Parser; | ||
| import view.InputView; | ||
| import view.OutputView; | ||
|
|
||
| public class JanggiController { | ||
|
|
||
| private final InputView inputView; | ||
| private final OutputView outputView; | ||
|
|
||
| public JanggiController(InputView inputView, OutputView outputView) { | ||
| this.inputView = inputView; | ||
| this.outputView = outputView; | ||
| } | ||
|
|
||
| public void run() { | ||
| Game game = initGame(); | ||
| processMove(game); | ||
| } | ||
|
|
||
| private Game initGame() { | ||
| Formation choformation = readChoFormation(); | ||
| Formation hanformation = readHanFormation(); | ||
|
|
||
| Board board = BoardFactory.createBoard(choformation, hanformation); | ||
| Game game = new Game(board); | ||
| outputView.printBoardStatus(game.getBoard()); | ||
| return game; | ||
| } | ||
|
|
||
| private void processMove(Game game) { | ||
| while (!game.isGameEnd()) { | ||
| Side currentTurn = game.getCurrentTurn(); | ||
| outputView.printCurrentTurn(currentTurn); | ||
| Position sourcePosition = readSourcePosition(); | ||
| Position targetPosition = readTargetPosition(); | ||
| try { | ||
| game.move(sourcePosition, targetPosition); | ||
| } catch (IllegalArgumentException e) { | ||
| outputView.printErrorMessage(e.getMessage()); | ||
| } | ||
| outputView.printBoardStatus(game.getBoard()); | ||
| } | ||
| } | ||
|
|
||
| private Position readSourcePosition() { | ||
| while (true) { | ||
| try { | ||
| int x = Parser.parseInput(inputView.readSourceXPosition()); | ||
| int y = Parser.parseInput(inputView.readSourceYPosition()); | ||
| return Position.of(x, y); | ||
| } catch (IllegalArgumentException e) { | ||
| outputView.printErrorMessage(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private Position readTargetPosition() { | ||
| while (true) { | ||
| try { | ||
| int x = Parser.parseInput(inputView.readTargetXPosition()); | ||
| int y = Parser.parseInput(inputView.readTargetYPosition()); | ||
| return Position.of(x, y); | ||
| } catch (IllegalArgumentException e) { | ||
| outputView.printErrorMessage(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private Formation readChoFormation() { | ||
| while (true) { | ||
| try { | ||
| String choFormation = inputView.readChoFormation(); | ||
| return Formation.from(choFormation); | ||
| } catch (IllegalArgumentException e) { | ||
| outputView.printErrorMessage(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private Formation readHanFormation() { | ||
| while (true) { | ||
| try { | ||
| String hanFormation = inputView.readHanFormation(); | ||
| return Formation.from(hanFormation); | ||
| } catch (IllegalArgumentException e) { | ||
| outputView.printErrorMessage(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package domain; | ||
|
|
||
| import domain.piece.Empty; | ||
| import domain.piece.King; | ||
| import domain.piece.Piece; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class Board { | ||
|
|
||
| private final Map<Position, Piece> board; | ||
|
|
||
| public Board(Map<Position, Piece> board) { | ||
| this.board = board; | ||
| } | ||
|
|
||
| public void movePiece(Position sourcePosition, Position targetPosition) { | ||
| board.put(targetPosition, board.get(sourcePosition)); | ||
| board.put(sourcePosition, new Empty()); | ||
| } | ||
|
|
||
| public Piece getPiece(Position position) { | ||
| return board.get(position); | ||
| } | ||
|
|
||
| public List<Piece> findPiecesOnRoute(List<Position> route, Position targetPosition) { | ||
| List<Piece> pieces = new ArrayList<>(); | ||
| for (Position position : route) { | ||
| if (!position.equals(targetPosition)) { | ||
| pieces.add(board.get(position)); | ||
| } | ||
| } | ||
| return pieces; | ||
| } | ||
|
|
||
| public boolean hasKing(Side side) { | ||
| for (Piece piece : board.values()) { | ||
| if (piece instanceof King && piece.isSameSide(side)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| public Map<Position, Piece> getBoard() { | ||
| return Map.copyOf(board); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package domain; | ||
|
|
||
| import constant.BoardSpec; | ||
| import domain.piece.Empty; | ||
| import domain.piece.Piece; | ||
| import domain.piece.PieceType; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class BoardFactory { | ||
|
|
||
| private static final int BACK_Y = 0; | ||
| private static final int KING_Y = 1; | ||
| private static final int CANNON_Y = 2; | ||
| private static final int SOLDIER_Y = 3; | ||
|
|
||
| private static final List<Integer> CANNON_X = List.of(2, 8); | ||
| private static final List<Integer> CHARIOT_X = List.of(1, 9); | ||
| private static final List<Integer> GUARD_X = List.of(4, 6); | ||
| private static final List<Integer> KING_X = List.of(5); | ||
| private static final List<Integer> SOLIDER_X = List.of(1, 3, 5, 7, 9); | ||
| private static final List<Integer> FORMATION_X = List.of(2, 3, 7, 8); | ||
|
|
||
| public static Board createBoard(Formation choFormation, Formation hanFormation) { | ||
| Map<Position, Piece> board = new HashMap<>(); | ||
| for (int x = BoardSpec.MIN_X; x <= BoardSpec.MAX_X; x++) { | ||
| for (int y = BoardSpec.MIN_Y; y <= BoardSpec.MAX_Y; y++) { | ||
| placePiece(board, Position.of(x, y), new Empty()); | ||
| } | ||
| } | ||
| placePieces(board, choFormation, Side.CHO); | ||
| placePieces(board, hanFormation, Side.HAN); | ||
|
|
||
| return new Board(board); | ||
| } | ||
|
|
||
| private static void placePieces(Map<Position, Piece> board, Formation formation, Side side) { | ||
| List<Integer> rows = getRowForSide(side); | ||
| placePiece(board, CANNON_X, rows.get(CANNON_Y), PieceType.CANNON, side); | ||
| placePiece(board, CHARIOT_X, rows.get(BACK_Y), PieceType.CHARIOT, side); | ||
| placePiece(board, GUARD_X, rows.get(BACK_Y), PieceType.GUARD, side); | ||
| placePiece(board, KING_X, rows.get(KING_Y), PieceType.KING, side); | ||
| placePiece(board, SOLIDER_X, rows.get(SOLDIER_Y), PieceType.SOLDIER, side); | ||
| placeFormationPiece(board, formation, FORMATION_X, rows.get(BACK_Y), side); | ||
| } | ||
|
|
||
| private static List<Integer> getRowForSide(Side side) { | ||
| if (side == Side.HAN) { | ||
| return List.of(1, 2, 3, 4); | ||
| } | ||
| return List.of(10, 9, 8, 7); | ||
| } | ||
|
|
||
| private static void placePiece(Map<Position, Piece> board, Position position, Piece piece) { | ||
| board.put(position, piece); | ||
| } | ||
|
|
||
| private static void placePiece(Map<Position, Piece> board, List<Integer> xPositions, int y, PieceType pieceType, | ||
| Side side) { | ||
| for (int x : xPositions) { | ||
| board.put(Position.of(x, y), pieceType.create(side)); | ||
| } | ||
| } | ||
|
|
||
| private static void placeFormationPiece(Map<Position, Piece> board, Formation formation, List<Integer> xPositions, | ||
| int y, Side side) { | ||
| List<PieceType> pieceTypes = formation.getPieceTypes(); | ||
| for (int i = 0; i < pieceTypes.size(); i++) { | ||
| board.put(Position.of(xPositions.get(i), y), pieceTypes.get(i).create(side)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package domain; | ||
|
|
||
| public enum Direction { | ||
| UP(0,-1), | ||
| DOWN(0, 1), | ||
| LEFT(-1, 0), | ||
| RIGHT(1, 0), | ||
| UP_LEFT(-1, -1), | ||
| UP_RIGHT(1, -1), | ||
| DOWN_LEFT(-1, 1), | ||
| DOWN_RIGHT(1, 1); | ||
|
|
||
| private final int x; | ||
| private final int y; | ||
|
|
||
| Direction(int x, int y) { | ||
| this.x = x; | ||
| this.y = y; | ||
| } | ||
|
|
||
| public int getX() { | ||
| return x; | ||
| } | ||
|
|
||
| public int getY() { | ||
| return y; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package domain; | ||
|
|
||
| import domain.piece.PieceType; | ||
| import java.util.List; | ||
|
|
||
| public enum Formation { | ||
| ์๋ง๋ง์("1", List.of(PieceType.ELEPHANT, PieceType.HORSE, PieceType.HORSE, PieceType.ELEPHANT)), | ||
| ๋ง์์๋ง("2", List.of(PieceType.HORSE, PieceType.ELEPHANT, PieceType.ELEPHANT, PieceType.HORSE)), | ||
| ์๋ง์๋ง("3", List.of(PieceType.ELEPHANT, PieceType.HORSE, PieceType.ELEPHANT, PieceType.HORSE)), | ||
| ๋ง์๋ง์("4", List.of(PieceType.HORSE, PieceType.ELEPHANT, PieceType.HORSE, PieceType.ELEPHANT)); | ||
|
|
||
| private static final String INVALID_OPTION_RANGE = "๋ฒํธ๋ 1~4 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค."; | ||
|
|
||
| private final String option; | ||
| private final List<PieceType> pieceTypes; | ||
|
|
||
| Formation(String option, List<PieceType> pieceTypes) { | ||
| this.option = option; | ||
| this.pieceTypes = pieceTypes; | ||
| } | ||
|
|
||
| public static Formation from(String input) { | ||
| for (Formation formation : Formation.values()) { | ||
| if (formation.option.equals(input)) { | ||
| return formation; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException(INVALID_OPTION_RANGE); | ||
| } | ||
|
|
||
| public List<PieceType> getPieceTypes() { | ||
| return pieceTypes; | ||
| } | ||
|
|
||
| public String toDisplayString() { | ||
| return option + ". " + name(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋๋ฉ์ธ ์์ธ ๋ฉ์์ง๋ฅผ ์ค์ฌ์ผ๋ก ์ฌ์ฉ์์๊ฒ ์ถ๋ ฅ์ ํ๊ณ ์๋๋ฐ, ๋ฉ์์ง์ ์๋ฏธ/์ ํ์ฑ์ด ์ถฉ๋ถํ์ง์
์ ๋ ฅ ํ์ฑ(nextInt) ์์ธ ์ฒ๋ฆฌ๋ฅผ View/Controller/Domain ์ด๋์์ ๋ด๋นํ๋ ๊ฒ ์ข์์ง ์๊ฒฌ ๋ถํ๋๋ฆฝ๋๋ค!
์์ฌ๋ ์๋ง๋ ์ ์ฒด๋ฅผ ํตํ์ด์ ์ง๋ฌธ์ ํ์ ๊ฒ ๊ฐ์๋ฐ์..!
์ํฉ์ ๋ฐ๋ผ ์กฐ๊ธ ๋ค๋ฅธ ๊ฒ ๊ฐ์์.
๋จ์ํ ์ ๋ ฅ๊ฐ์๋ํ ์ ๋ ฅ ํ์ ๋ฌธ์ ๋ View๋ Controller ์ชฝ์์ ์ฒ๋ฆฌํ๋๊ฒ ์์ฐ์ค๋ฝ์ง๋ง
์กธ๋ณ์ ๋ ์นธ ์ ์ง์์ผฐ๋ค๊ฑฐ๋ํ๋ ์ผ์ด์ค๋ ๋๋ฉ์ธ ๊ท์น์ ์๋ฐฐ๋๋ ๊ฒฝ์ฐ์ด๋ฏ๋ก ์ด๋ฐ ๊ฒฝ์ฐ์๋ Domain์์ ์์ธ์ฒ๋ฆฌ๋ฅผ ํด์ผํ๋ค๊ณ ์๊ฐํด์. ๐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฉ์์ง์ ์๋ฏธ/์ ํ์ฑ์ ๊ผผ๊ผผํ๊ฒ ๋ค ์ดํด๋ณด์ง๋ ๋ชปํ์ง๋ง, ๋จ๊ธด ์ฝ๋ฉํธ์ค์์ ์ํฉ์ ๋ง์ง์๋ ์์ธ ์ฒ๋ฆฌ๊ฐ ์์๋ ๊ฒ ๊ฐ์๋ฐ์. ์์ธ ๋ฉ์์ง์ ์๋ฏธ/์ ํ์ฑ์ด๋๊ฒ ๋ฑ ์ ์๋ ๊ฒ์ ์์ง๋ง, ๊ฒฐ๊ตญ
์์ธ ๋ฉ์์ง๋ฅผ ์ ๋จ๊ธฐ๋์ง?์ ๋ํด์ ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์์.๊ฒฐ๊ตญ์๋ ์์ธ ์ํฉ์ ํ์ํ๊ณ ์ ์ ํ ์ฒ๋ฆฌ๋ฅผ ํ๊ธฐ์ํจ์ด๋ผ๊ณ ์๊ฐํ๋๋ฐ์.
๊ทธ๋ ๋ค๋ฉด ํด๋น ์์ธ ์ํฉ์ด ์ ๋ฐ์ํ๋์ง๋ฅผ ์ ๋๋ฌ๋ด์ผํ๋ค๊ณ ์๊ฐํด์.
๋ ๋ ๋์๊ฐ์ ์ค์ ์ด์ํ๊ฒฝ์์ ๋ฒ๊ทธ๊ฐ ๋ฐ์ํ์ฌ ์ฅ์ ๋์์ ํ๋ค๊ณ ์๊ฐํด๋ณด๋ฉด ๊ฒฐ๊ตญ ๋๋ฒ๊น ์ ์์์ ์ด ์ด ์์ธ๋ฉ์์ง๋ผ๊ณ ์๊ฐํด์.
์ด ์์ธ๋ฉ์์ง๊ฐ ๋๋ฒ๊น ์ ์์ ํฌ์ธํธ๋ผ๊ณ ์๊ฐํ๋ฉด....! ์ ๋ง ์ค์ํ๋ค๊ณ ์๊ฐํ์์ง ์๋์? ๐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ธ ๋ฉ์ธ์ง์ ์ ๊ฒฝ์ ์ ์ฐ์ง ๋ชปํ๋ ๊ฒฝ์ฐ๋ ์์๋๋ฐ, ์์ผ๋ก ๋ ๋ฉด๋ฐํ ์์ฑํ๋๋ก ํ๊ฒ ์ต๋๋คโบ๏ธ ๋ต๋ณ ์ ๋ง ๊ฐ์ฌํฉ๋๋ค!