-
Notifications
You must be signed in to change notification settings - Fork 3
박찬인 - 사다리 게임 #2
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
pci2676
wants to merge
17
commits into
Java-Bom:pci
Choose a base branch
from
pci2676:pci
base: pci
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
박찬인 - 사다리 게임 #2
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b19c86c
team1
pci2676 790737a
방향 enum으로 작성
pci2676 7048b6a
기둥 랜덤생성 완료
pci2676 7b3e437
동기화된 기둥 생성
pci2676 ebec579
사다리 출력 공백 조절 필요
pci2676 1376e63
사다리 출력완료
pci2676 7a56583
오류찾음
pci2676 aac7c58
사다리 게임
pci2676 92571c6
Add exception test
pci2676 350af1e
Add exception for negative location value
pci2676 4938f6c
생성자 변경
pci2676 317b375
불필요한 변수 전달 삭제
pci2676 b15e45d
테스트 코드 수정
pci2676 ff26a8c
메소드 클래스 내부 위치 변경
pci2676 ea9ee79
리펙토링
pci2676 332e741
direction refactoring
pci2676 5e85435
추가요구사항 작성
pci2676 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
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,34 +1,31 @@ | ||
| package domain.direction; | ||
|
|
||
| import java.util.Arrays; | ||
| import domain.ladder.Point; | ||
|
|
||
| public enum Direction { | ||
| RIGHT(1), | ||
| DOWN(2), | ||
| LEFT(3); | ||
| import java.util.Random; | ||
|
|
||
| private int code; | ||
| public enum Direction { | ||
|
|
||
| Direction(int code) { | ||
| this.code = code; | ||
| } | ||
|
|
||
| public int getCode() { | ||
| return code; | ||
| } | ||
| RIGHT, | ||
| DOWN, | ||
| LEFT; | ||
|
|
||
| public boolean isRight() { | ||
| return this == Direction.RIGHT; | ||
| } | ||
|
|
||
| public static Direction findByCode(int code) { | ||
| return Arrays.stream(Direction.values()) | ||
| .filter(direction -> direction.hasCode(code)) | ||
| .findFirst() | ||
| .orElse(DOWN); | ||
| public static Direction getRightOrDown() { | ||
| return new Random().nextBoolean() ? RIGHT : DOWN; | ||
| } | ||
|
|
||
| public static Direction createMidDirection(Point point) { | ||
| if (point.isRight()) { | ||
| return Direction.LEFT; | ||
| } | ||
| return Direction.getRightOrDown(); | ||
| } | ||
|
|
||
| private boolean hasCode(int code) { | ||
| return this.code == code; | ||
| public static Direction createLastDirection(Point point) { | ||
| return point.isRight() ? LEFT : DOWN; | ||
| } | ||
| } | ||
This file was deleted.
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
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,30 @@ | ||
| package domain.ladder; | ||
|
|
||
| import domain.direction.Direction; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| public class PointGenerator { | ||
|
|
||
| public static List<Point> createFirst(int height) { | ||
| return IntStream.range(0, height) | ||
| .mapToObj(y -> new Location(0, y)) | ||
| .map(location -> new Point(location, Direction.getRightOrDown())) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public static List<Point> createMiddle(List<Point> before) { | ||
| return before.stream() | ||
| .map(point -> Point.createNextPoint(point, Direction.createMidDirection(point))) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public static List<Point> createLast(List<Point> points) { | ||
| return points.stream() | ||
| .map(point -> Point.createNextPoint(point, Direction.createLastDirection(point))) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| } |
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
...a/domain/ladderFactory/LadderFactory.java → ...n/ladder/ladderFactory/LadderFactory.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 domain.ladderFactory; | ||
| package domain.ladder.ladderFactory; | ||
|
|
||
| import domain.ladder.Pillar; | ||
|
|
||
|
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.