-
Notifications
You must be signed in to change notification settings - Fork 743
๐ 3๋จ๊ณ - ์ฌ๋ค๋ฆฌ(๊ฒ์ ์คํ) #2432
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
Changes from all commits
945fbd6
50713df
5fa23de
e636d24
d74b614
40bf287
9028b99
0e2467d
1832913
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # ๐ 3๋จ๊ณ - ์ฌ๋ค๋ฆฌ(๊ฒ์ ์คํ) | ||
|
|
||
| *** | ||
|
|
||
| ## ์ฝ๋ ๋ฆฌ๋ทฐ | ||
|
|
||
| > PR ๋งํฌ : | ||
|
|
||
| ## ๋์ ํ์ต ๋ชฉํ | ||
|
|
||
| ### 1. TDD ์ฌ์ดํด์ ์ต๊ดํ ํ์. | ||
|
|
||
| ### 2. ๊ฐ์ฒด์งํฅ ์ํ ์ฒด์กฐ ์์น์ ์ค์ํ์. | ||
|
|
||
| ### 3. ๋ค์ด๋ฐ ์์ฑํ ๋ AI๋ฅผ ์ ๊ทน ํ์ฉํ์. | ||
|
|
||
| # ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ | ||
|
|
||
| - ์ฌ๋ค๋ฆฌ ์คํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํด์ผ ํ๋ค. | ||
| - ๊ฐ์ธ๋ณ ์ด๋ฆ์ ์ ๋ ฅํ๋ฉด ๊ฐ์ธ๋ณ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๊ณ , "all"์ ์ ๋ ฅํ๋ฉด ์ ์ฒด ์ฐธ์ฌ์์ ์คํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ค. | ||
|
|
||
| # ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ | ||
|
|
||
| - ์๋ฐ 8์ ์คํธ๋ฆผ๊ณผ ๋๋ค๋ฅผ ์ ์ฉํด ํ๋ก๊ทธ๋๋ฐํ๋ค. | ||
| - ๊ท์น 6: ๋ชจ๋ ์ํฐํฐ๋ฅผ ์๊ฒ ์ ์งํ๋ค. | ||
| - ๊ท์น 7: 3๊ฐ ์ด์์ ์ธ์คํด์ค ๋ณ์๋ฅผ ๊ฐ์ง ํด๋์ค๋ฅผ ์ฐ์ง ์๋๋ค. | ||
|
|
||
| # ์คํ ๊ฒฐ๊ณผ | ||
|
|
||
| ``` | ||
| ์ฐธ์ฌํ ์ฌ๋ ์ด๋ฆ์ ์ ๋ ฅํ์ธ์. (์ด๋ฆ์ ์ผํ(,)๋ก ๊ตฌ๋ถํ์ธ์) | ||
| pobi,honux,crong,jk | ||
|
|
||
| ์คํ ๊ฒฐ๊ณผ๋ฅผ ์ ๋ ฅํ์ธ์. (๊ฒฐ๊ณผ๋ ์ผํ(,)๋ก ๊ตฌ๋ถํ์ธ์) | ||
| ๊ฝ,5000,๊ฝ,3000 | ||
|
|
||
| ์ต๋ ์ฌ๋ค๋ฆฌ ๋์ด๋ ๋ช ๊ฐ์ธ๊ฐ์? | ||
| 5 | ||
|
|
||
| ์ฌ๋ค๋ฆฌ ๊ฒฐ๊ณผ | ||
|
|
||
| pobi honux crong jk | ||
| |-----| |-----| | ||
| | |-----| | | ||
| |-----| | | | ||
| | |-----| | | ||
| |-----| |-----| | ||
| ๊ฝ 5000 ๊ฝ 3000 | ||
|
|
||
| ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ์ถ์ ์ฌ๋์? | ||
| pobi | ||
|
|
||
| ์คํ ๊ฒฐ๊ณผ | ||
| ๊ฝ | ||
|
|
||
| ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ์ถ์ ์ฌ๋์? | ||
| all | ||
|
|
||
| ์คํ ๊ฒฐ๊ณผ | ||
| pobi : ๊ฝ | ||
| honux : 3000 | ||
| crong : ๊ฝ | ||
| jk : 5000 | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package nextstep.ladder.domain.ladder; | ||
|
|
||
| import nextstep.ladder.domain.user.User; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class LadderResult { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ |
||
|
|
||
| private final User user; | ||
| private final Reward reward; | ||
|
|
||
| public LadderResult(User user) { | ||
| this(user, null); | ||
| } | ||
|
|
||
| public LadderResult(User user, Reward reward) { | ||
| this.user = user; | ||
| this.reward = reward; | ||
| } | ||
|
|
||
| public User getUser() { | ||
| return user; | ||
| } | ||
|
|
||
| public Reward getReward() { | ||
| return this.reward; | ||
| } | ||
|
|
||
| public String getUserValue() { | ||
| return this.user.getNameValue(); | ||
| } | ||
|
|
||
| public String getRewardValue() { | ||
| return this.reward.getReward(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "LadderResult{" + | ||
| "user=" + user + | ||
| ", reward=" + reward + | ||
| '}'; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| LadderResult that = (LadderResult) o; | ||
| return Objects.equals(getUser(), that.getUser()) && Objects.equals(getReward(), that.getReward()); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(getUser(), getReward()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package nextstep.ladder.domain.ladder; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class LadderResults { | ||
|
|
||
| private List<LadderResult> results; | ||
|
|
||
| public LadderResults(LadderResult... results) { | ||
| this(List.of(results)); | ||
| } | ||
|
|
||
| public LadderResults(List<LadderResult> results) { | ||
| this.results = results; | ||
| } | ||
|
|
||
| public List<LadderResult> getResults() { | ||
| return results; | ||
| } | ||
|
|
||
| public int size() { | ||
| return this.results.size(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "LadderResults{" + | ||
| "results=" + results + | ||
| '}'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,24 +6,45 @@ | |
|
|
||
| public class Line { | ||
|
|
||
| private List<Boolean> line; | ||
| private List<Boolean> lines; | ||
|
|
||
| public Line(int row, GenerateLadderLineStrategy generate) { | ||
| this.line = generate.generate(row); | ||
| this.lines = generate.generate(row); | ||
| } | ||
|
|
||
| public int size(){ | ||
| return this.line.size(); | ||
| public int size() { | ||
| return this.lines.size(); | ||
| } | ||
|
|
||
| public List<Boolean> getLine() { | ||
| return line; | ||
| public List<Boolean> getLines() { | ||
| return lines; | ||
| } | ||
|
|
||
| public int move(int position) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ |
||
| if (isMoveRight(position)) { | ||
| return ++position; | ||
| } | ||
|
|
||
| if (isMoveLeft(position)) { | ||
| return --position; | ||
| } | ||
|
|
||
| return position; | ||
| } | ||
|
|
||
| private boolean isMoveRight(int position) { | ||
| return position < lines.size() && lines.get(position); | ||
| } | ||
|
|
||
| public boolean isMoveLeft(int position) { | ||
| return position > 0 && lines.get(position - 1); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Line{" + | ||
| "line=" + line + | ||
| "line=" + lines + | ||
| '}'; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package nextstep.ladder.domain.ladder; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class Reward { | ||
|
|
||
| private final String reward; | ||
|
|
||
| public Reward(String reward) { | ||
| this.reward = reward; | ||
| } | ||
|
|
||
| public String getReward() { | ||
| return reward; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Reward{" + | ||
| "reward='" + reward + '\'' + | ||
| '}'; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| Reward reward1 = (Reward) o; | ||
| return Objects.equals(reward, reward1.reward); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(reward); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package nextstep.ladder.domain.ladder; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| public class Rewards { | ||
|
|
||
| private final List<Reward> rewards; | ||
|
|
||
| public Rewards(String rewards) { | ||
| this(Arrays.stream(validateReward(rewards).split(",")) | ||
| .map(Reward::new) | ||
| .toList()); | ||
| } | ||
|
|
||
| public Rewards(List<Reward> rewards) { | ||
| this.rewards = rewards; | ||
| } | ||
|
|
||
| public static String validateReward(String reward) { | ||
| if (Objects.isNull(reward) || reward.isBlank()) { | ||
| throw new IllegalArgumentException("๊ฒฐ๊ณผ ์ ๋ ฅ์ ํ์์ ๋๋ค."); | ||
| } | ||
| return reward; | ||
| } | ||
|
|
||
| public int size() { | ||
| return this.rewards.size(); | ||
| } | ||
|
|
||
| public List<Reward> getRewards() { | ||
| return rewards; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Rewards{" + | ||
| "rewards=" + rewards + | ||
| '}'; | ||
| } | ||
|
|
||
| public Reward findReward(int position) { | ||
| return rewards.get(position); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package nextstep.ladder.domain.strategy; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class FixedLadderLineGenerateStrategy implements GenerateLadderLineStrategy { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FixedLadderLineGenerateStrategy์ ๊ตณ์ด ์ถ๊ฐํ๊ธฐ๋ณด๋ค ๋๋ค๋ก ํ ์คํธ ์ฝ๋๋ฅผ ๊ตฌํํ๋๋ก ํ๋ฉด ์ด๋จ๊น? |
||
|
|
||
| private final List<Boolean> pattern; | ||
|
|
||
| public FixedLadderLineGenerateStrategy(Boolean... pattern) { | ||
| this.pattern = List.of(pattern); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Boolean> generate(int size) { | ||
| validatePattern(size); | ||
| return pattern; | ||
| } | ||
|
|
||
| private void validatePattern(int size) { | ||
| if (size - 1 != pattern.size()) { | ||
| throw new IllegalArgumentException("ํจํด ํฌ๊ธฐ์ ์์ฒญ ํฌ๊ธฐ๊ฐ ์ผ์นํ์ง ์์ต๋๋ค."); | ||
| } | ||
| } | ||
| } | ||
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.
Rewards๊ฐ null์ธ ์ํ์ ์ฌ๋ค๋ฆฌ ํ๊ธฐ๊ฐ ๊ฐ๋ฅํ๊ฐ?
Rewards๊ฐ ํ์๋ผ๋ฉด ์ด ์์ฑ์๋ ์ ๊ฑฐํด๋ ๋์ง ์์๊น?