Skip to content
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

๐Ÿš€ 2๋‹จ๊ณ„ - ์‚ฌ๋‹ค๋ฆฌ(์ƒ์„ฑ) #1963

Open
wants to merge 6 commits into
base: jeounpar
Choose a base branch
from

Conversation

jeounpar
Copy link

์•ˆ๋…•ํ•˜์„ธ์š”! ์‚ฌ๋‹ค๋ฆฌ ๋ฏธ์…˜ 2๋‹จ๊ณ„ ๋ฆฌ๋ทฐ ์š”์ฒญ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

Copy link
Member

@testrace testrace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•ˆ๋…•ํ•˜์„ธ์š” ์ •๊ทœ๋‹˜
๋ช‡ ๊ฐ€์ง€ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒจ๋‘์—ˆ๋Š”๋ฐ ํ™•์ธํ•ด ์ฃผ์‹œ๊ณ  ๋‹ค์‹œ ๋ฆฌ๋ทฐ ์š”์ฒญ ๋ถ€ํƒ๋“œ๋ ค์š”

Comment on lines +12 to +17
public Ladder(LadderHeight heightOfLadder, PersonCount countOfPerson, Random random) {
this.lines = new ArrayList<>();
IntStream.range(0, heightOfLadder.getHeightOfLadder())
.mapToObj(line -> new Line(countOfPerson.getCountOfPerson(), random))
.forEach(this.lines::add);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ƒ์„ฑ์ž์— ๋กœ์ง์ด ํฌํ•จ๋˜์—ˆ๋„ค์š”
๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด ๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

IntStream ์€ for๋ฌธ์œผ๋กœ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์€๋ฐ์š”
IntStream ์œผ๋กœ Line ๊ฐ์ฒด๋“ค์„ ์ƒ์„ฑํ•˜์‹  ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค

Random์„ ์ธ์ž๋กœ ๋ฐ›์œผ๋ฉด ๋ฉฑ๋“ฑ์„ฑ์ด ์ง€์ผœ์ง€์ง€ ์•Š๋Š” ๊ฒƒ ๊ฐ™์•„์š”
๋žœ๋ค์„ ์‚ฌ์šฉํ•˜๋”๋ผ๋„ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์„œ Ladder๋Š” ์ธํ„ฐํŽ˜์ด์Šค์— ์˜์กดํ•˜๋„๋ก ๋ณ€๊ฒฝํ•˜๋ฉด ์–ด๋–จ๊นŒ์š”?


private static final int MIN_HEIGHT = 1;

private final Integer heightOfLadder;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapper ํƒ€์ž…์€ NPE๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค
๊ผญ ์จ์•ผํ•˜๋Š” ์ด์œ ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด ์›์‹œ ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜๋ฉด ์–ด๋–จ๊นŒ์š”?

import java.util.List;
import java.util.Random;

public class LadderService {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ฃผ์„, ์ฝ”๋“œ(import ํฌํ•จ)์€ ์ œ๊ฑฐํ•ด ์ฃผ์„ธ์š”

Comment on lines +12 to +18
public Line(int countOfPerson, Random random) {
this.points = new ArrayList<>();
this.points.add(random.nextBoolean());
IntStream.range(0, countOfPerson - 2)
.forEach(index -> initPoint(index, random.nextBoolean()));
validateLine(countOfPerson);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ๋„ ์ƒ์„ฑ์ž ๋‚ด๋ถ€์— ๋กœ์ง์ด ์žˆ๋„ค์š”
์ธ์ž countOfPerson ์€ PersonCount ํƒ€์ž…์„ ํ™œ์šฉํ•˜๋ฉด ์–ด๋–จ๊นŒ์š”?

๊ฐ€๋กœ๋ผ์ธ์€ ๊ฒน์น  ์ˆ˜ ์—†๋‹ค๋Š” ์š”๊ตฌ์‚ฌํ•ญ์€ Line์˜ ์ฑ…์ž„์ผ ๊ฒƒ ๊ฐ™์€๋ฐ์š”
์ƒ์„ฑ์ž์— ๋กœ์ง์ด ์žˆ์–ด์„œ ์š”๊ตฌ์‚ฌํ•ญ์„ ๊ฒ€์ฆํ•  ์ˆ˜ ์—†์„ ๊ฒƒ ๊ฐ™์•„์š”
์š”๊ตฌ์‚ฌํ•ญ์„ ๊ฒ€์ฆํ•  ์ˆ˜ ์žˆ๋Š” ๊ตฌ์กฐ๋ฅผ ๊ณ ๋ฏผํ•ด ๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”

Comment on lines +29 to +36
if (this.points.get(index) && nextBoolean || this.points.get(index) && !nextBoolean
|| !this.points.get(index) && !nextBoolean) {
this.points.add(false);
return;
}
if (!this.points.get(index) && nextBoolean) {
this.points.add(true);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getter๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์ด ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋Š” ๊ฒƒ ๊ฐ™์•„์š”
๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด์„œ ํ•ด๊ฒฐํ•  ์ˆ˜ ์—†๋Š”์ง€, ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ ๊ฐ์ฒด๋ฅผ ๋„์ถœํ•  ์ˆ˜ ์—†๋Š”์ง€ ๊ณ ๋ฏผํ•ด ๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”

Comment on lines +24 to +29
@Override
public String toString() {
return IntStream.range(0, MAX_LENGTH - name.length())
.mapToObj(i -> SPACE)
.collect(Collectors.joining("", name, ""));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ถœ๋ ฅ์„ ์œ„ํ•ด์„œ ๊ณต๋ฐฑ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋กœ์ง์„ ์ถœ๋ ฅ์˜ ์ฑ…์ž„ ์•„๋‹๊นŒ์š”?
์ฐธ๊ฐ€์ž๊ฐ€ ๋งŽ์€ ๊ฒฝ์šฐ ์‚ฌ๋‹ค๋ฆฌ์˜ ์‹œ์ž‘ ์œ„์น˜์— ์ด๋ฆ„์ด ์ถœ๋ ฅ๋˜๊ณ  ์žˆ์ง€ ์•Š์•„์š”
image

Comment on lines +11 to +23
@Test
@DisplayName("์‚ฌ๋‹ค๋ฆฌ์˜ ๋†’์˜๋Š” 1 ์ด์ƒ์ด๋‹ค")
void ladder_height() {
Assertions.assertThatThrownBy(() -> {
new LadderHeight(0);
}).isInstanceOf(IllegalArgumentException.class)
.hasMessage("๋†’์ด๋Š” 1 ์ด์ƒ ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");

Assertions.assertThatThrownBy(() -> {
new LadderHeight(-1);
}).isInstanceOf(IllegalArgumentException.class)
.hasMessage("๋†’์ด๋Š” 1 ์ด์ƒ ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฒฝ๊ณ„๊ฐ’์ธ 0์œผ๋กœ ๊ฒ€์ฆํ–ˆ๋Š”๋ฐ ์ถ”๊ฐ€๋กœ -1๋„ ๊ฒ€์ฆํ•˜์‹  ์ด์œ ๊ฐ€ ์žˆ์œผ์‹ ๊ฐ€์š”?

Comment on lines +16 to +19
@Test
void ladder() {
Ladder ladder = new Ladder(new LadderHeight(5), new PersonCount(4), new AlwaysReturnTrue());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‹จ์œ„ ํ…Œ์ŠคํŠธ ์ž‘์„ฑ์ด ๋ˆ„๋ฝ๋˜์—ˆ๋„ค์š”

Comment on lines +19 to +27
@Test
@DisplayName("์‚ฌ๋‹ค๋ฆฌ์˜ ๋ผ์ธ ํ•˜๋‚˜๋ฅผ ์ƒ์„ฑํ•œ๋‹ค")
void line() {
int countOfPerson = 5;
Line line = new Line(countOfPerson, new AlwaysReturnTrue());

assertThat(line.getPoints()).hasSize(countOfPerson - 1)
.containsExactly(true, false, true, false);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DisplayName๊ณผ ํ…Œ์ŠคํŠธ ๋‚ด์šฉ์ด ์ผ์น˜ ํ•˜์ง€ ์•Š๋„ค์š”
ํ…Œ์ŠคํŠธ์˜ ์˜๋„์™€ ํ…Œ์ŠคํŠธ ๋‚ด์šฉ์„ ์ผ์น˜ ์‹œ์ผœ์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”

์ถ”๊ฐ€๋กœ ๊ฐ€๋กœ ๋ผ์ธ์€ ๊ฒน์น  ์ˆ˜ ์—†๋‹ค๋Š” ์š”๊ตฌ์‚ฌํ•ญ์ด ์žˆ๋Š”๋ฐ ์ด ๊ฒ€์ฆ์€ ์–ด๋–ป๊ฒŒ ํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”?

Comment on lines +9 to +18
class OutputViewTest {

@Test
void print_ladder() {
Ladder ladder = new Ladder(new LadderHeight(10), new PersonCount(5),
new RandomTrueOrFalse());
OutputView outputView = new OutputView();
// outputView.printLadder(ladder);

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ…Œ์ŠคํŠธ๊ฐ€ ํ•„์š”ํ•˜๋‹ค๋ฉด ํ…Œ์ŠคํŠธ๋ฅผ ๋งˆ์ € ์ž‘์„ฑํ•ด ์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants