-
Notifications
You must be signed in to change notification settings - Fork 26
2주차 미션 / 서버 3조 김상균 #33
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
ksg1227
wants to merge
16
commits into
Konkuk-KUIT:1week-completed
Choose a base branch
from
ksg1227:ksg1227-week2
base: 1week-completed
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
16 commits
Select commit
Hold shift + click to select a range
0b5bb50
feat: 사다리 출력 기능 완성
ksg1227 019db05
test: 사다리 출력 기능 테스트
ksg1227 dce5bbe
feat: 사다리 자동 생성 기능 추가
ksg1227 556855d
test: 사다리 자동 생성 기능 테스트
ksg1227 cb62bdb
refactor: LadderCreator 인터페이스 도입
ksg1227 d726d37
test: 인터페이스 도입 후 구현체 검증
ksg1227 e761bc5
refactor & test: 정적 팩토리 메서드 패턴 활용 및 테스트 코드 일부 작성
ksg1227 1a12f35
refactor: LadderSize 클래스 활용
ksg1227 ed31c2c
test: LadderSize 적용
ksg1227 0ba7707
refactor: LadderPosition 클래스 생성
ksg1227 692ad2b
refactor: LadderPosition 적용
ksg1227 33ec7a3
refactor: TimeLine Enum 클래스 활용
ksg1227 ef1b430
refactor: LadderPrinter 클래스 활용 및 package 분리
ksg1227 0fe3fd8
refactor: 사다리 출력 간소화
ksg1227 3172137
refactor: getNumberOfLine() 메서드를 AutoLadderCreatorImpl 클래스에서 LadderSi…
ksg1227 9664d0b
refactor: 리뷰에 맞게 리팩토링
ksg1227 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,19 @@ | ||
| package ladder; | ||
|
|
||
| import ladder.component.GreaterThanOne; | ||
| import ladder.component.LadderSize; | ||
| import ladder.creator.AutoLadderCreatorImpl; | ||
| import ladder.creator.BasicLadderCreatorImpl; | ||
| import ladder.creator.LadderCreator; | ||
|
|
||
| public class LadderGameFactory { | ||
|
|
||
| public static LadderGame createRandomLadderGame(LadderSize ladderSize) { | ||
| return new LadderGame(new AutoLadderCreatorImpl(ladderSize)); | ||
| } | ||
|
|
||
| public static LadderGame createBasicLadderGame(LadderSize ladderSize) { | ||
| return new LadderGame(new BasicLadderCreatorImpl(ladderSize)); | ||
| } | ||
| } | ||
|
|
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,17 +1,35 @@ | ||
| package ladder; | ||
|
|
||
| import ladder.component.LadderPosition; | ||
| import ladder.component.Position; | ||
| import ladder.component.Row; | ||
| import ladder.printer.LadderPrinter; | ||
|
|
||
| import static ladder.constant.TimeLine.*; | ||
|
|
||
| public class LadderRunner { | ||
|
|
||
| private final Row[] rows; | ||
| private final LadderPrinter ladderPrinter; | ||
|
|
||
| public LadderRunner(Row[] rows) { | ||
| this.rows = rows; | ||
| this.ladderPrinter = LadderPrinter.from(rows); | ||
| } | ||
|
|
||
| public int run(Position position) { | ||
|
|
||
| for (int i = 0; i < rows.length; i++) { | ||
|
|
||
| ladderPrinter.printWholeLine(LadderPosition.from(Position.from(i), position), BEFORE); | ||
|
|
||
| rows[i].nextPosition(position); | ||
|
|
||
| ladderPrinter.printWholeLine(LadderPosition.from(Position.from(i), position), AFTER); | ||
|
|
||
| } | ||
|
|
||
| return position.getValue(); | ||
| } | ||
|
|
||
| } |
4 changes: 3 additions & 1 deletion
4
src/main/java/ladder/GreaterThanOne.java → ...java/ladder/component/GreaterThanOne.java
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
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 ladder.component; | ||
|
|
||
| public class LadderPosition { | ||
|
|
||
| private Position row; | ||
| private Position col; | ||
|
|
||
| private LadderPosition(Position row, Position col) { | ||
| this.row = row; | ||
| this.col = col; | ||
| } | ||
|
|
||
| public static LadderPosition from(Position row, Position col) { | ||
| return new LadderPosition(row, col); | ||
| } | ||
|
|
||
| public Position getRow() { | ||
| return row; | ||
| } | ||
|
|
||
| public Position getCol() { | ||
| return col; | ||
| } | ||
|
|
||
| public boolean isCurrentRow(Position row) { | ||
| return this.row.getValue() == row.getValue(); | ||
| } | ||
| } |
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,26 @@ | ||
| package ladder.component; | ||
|
|
||
| public class LadderSize { | ||
|
|
||
| GreaterThanOne numberOfRow; | ||
| GreaterThanOne numberOfPerson; | ||
|
|
||
| private LadderSize(GreaterThanOne numberOfRow, GreaterThanOne numberOfPerson) { | ||
| this.numberOfRow = numberOfRow; | ||
| this.numberOfPerson = numberOfPerson; | ||
| } | ||
|
|
||
| public static LadderSize from(GreaterThanOne numberOfRow, GreaterThanOne numberOfPerson) { | ||
| return new LadderSize(numberOfRow, numberOfPerson); | ||
| } | ||
|
|
||
| public GreaterThanOne getNumberOfRow() { | ||
| return numberOfRow; | ||
| } | ||
|
|
||
| public GreaterThanOne getNumberOfPerson() { | ||
| return numberOfPerson; | ||
| } | ||
|
|
||
|
|
||
| } |
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
4 changes: 2 additions & 2 deletions
4
src/main/java/ladder/Position.java → src/main/java/ladder/component/Position.java
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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/ladder/Direction.java → src/main/java/ladder/constant/Direction.java
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,4 +1,4 @@ | ||
| package ladder; | ||
| package ladder.constant; | ||
|
|
||
| public enum Direction { | ||
|
|
||
|
|
||
2 changes: 1 addition & 1 deletion
2
src/main/java/ladder/ExceptionMessage.java → ...ava/ladder/constant/ExceptionMessage.java
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,4 +1,4 @@ | ||
| package ladder; | ||
| package ladder.constant; | ||
|
|
||
| public enum ExceptionMessage { | ||
|
|
||
|
|
||
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.
해당 로직이 getNodes().length() 이렇게 활용되는데 getNodes를 통해 캡슐화를 깨뜨릴 필요가 있을까요? getNodesLength()를 사용하거나, LadderSize 를 사용하는게 바람직해 보입니다.