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๋‹จ๊ณ„ - ์‚ฌ๋‹ค๋ฆฌ(์ƒ์„ฑ) #2120

Open
wants to merge 36 commits into
base: sang5c
Choose a base branch
from

Conversation

sang5c
Copy link

@sang5c sang5c commented Apr 7, 2024

์ •๋ง ์˜ค๋žœ๋งŒ์— ์‚ฌ๋‹ค๋ฆฌ ๊ฒŒ์ž„์„ ์ž‘์„ฑํ•ด๋ดค์Šต๋‹ˆ๋‹ค.
๋งˆ์Œ์˜ ์ง์„ ์•ฝ๊ฐ„์ด๋‚˜๋งˆ ๋œ์–ด๋‚ธ ๊ฒƒ ๊ฐ™๋„ค์š” ใ…Žใ…Ž

์ž˜ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ™‡

sang5c added 30 commits April 3, 2024 00:18
@@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'eclipse'

version = '1.0.0'
sourceCompatibility = 1.8
sourceCompatibility = 11
Copy link
Author

Choose a reason for hiding this comment

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

๋ฏธ์…˜ ๋‹ค์‹œ ์‹œ์ž‘ํ•  ๋• ๋ฆฌ๋ทฐ์š”์ฒญ์„ ์—ผ๋‘์— ๋‘์ง€ ์•Š๊ณ  ์ง„ํ–‰ํ•ด์„œ ์ž๋ฐ” ๋ฒ„์ „์„ ๋ฐ”๊ฟจ์—ˆ๋Š”๋ฐ์š”!
ํ˜น์‹œ ๋ฒ„์ „๋‹ค์šด์ด ํ•„์š”ํ•˜๋ฉด ๋‚ด๋ฆฌ๊ณ  ๋‹ค์‹œ ์š”์ฒญ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค!

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

public class LineBuilder {
Copy link
Author

Choose a reason for hiding this comment

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

LineBuilder ํด๋ž˜์Šค์˜ ์œ„์น˜์— ๋Œ€ํ•ด ๊ณ ๋ฏผ์ด ๋งŽ์•˜์Šต๋‹ˆ๋‹ค.
๋ณ„๋„์˜ ํด๋ž˜์Šค๋กœ ๋ถ„๋ฆฌํ•˜๋Š”๊ฒŒ ์ข‹์„์ง€ Line ํด๋ž˜์Šค ๋‚ด๋ถ€์— ์žˆ์–ด์•ผ ํ• ์ง€ ๊ณ ๋ฏผํ•˜๋‹ค๊ฐ€ Factory์˜ ์—ญํ• ๋„ ์ผ๋ถ€ ์ˆ˜ํ–‰ํ•œ๋‹ค๊ณ  ๋Š๊ปด์ ธ์„œ ๋ณ„๋„๋กœ ๋ถ„๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.

Choose a reason for hiding this comment

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

ํŒฉํ† ๋ฆฌ๋ฅผ ์จ์„œ ์–ป๊ณ ์ž ํ•˜๋Š” ์ด๋“์ด ๋ฌด์—‡์ธ๊ฐ€์š”? ๐Ÿค” ๐Ÿ’ญ

Choose a reason for hiding this comment

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

์ œ๊ฐ€ ์ƒ๊ฐํ•˜๋Š” ํŒฉํ† ๋ฆฌ์˜ ์žฅ์ ์€ ์•„๋ž˜ ์ •๋„์ธ๋ฐ ํ•ด๋‹น์‚ฌํ•ญ์ด ์—†๋Š”๊ฒƒ ๊ฐ™์•„์„œ์š” ๐Ÿค”

๊ฐ์ฒด ์ƒ์„ฑ์— ์กฐ๊ฑด์ด ์žˆ์„ ๋•Œ: ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์กฐ๊ฑด์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์ข…๋ฅ˜์˜ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ, ํŒฉํ† ๋ฆฌ ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜์—ฌ ์กฐ๊ฑด์— ๋”ฐ๋ผ ์ ์ ˆํ•œ ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ตฌํ˜„์„ ๋ณ€๊ฒฝํ•  ํ•„์š”๊ฐ€ ์žˆ์„ ๋•Œ: ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ ๊ตฌํ˜„ ํด๋ž˜์Šค ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์—ฌ, ์ถ”ํ›„ ๊ตฌํ˜„์„ ๋ณ€๊ฒฝํ•  ๋•Œ ๊ธฐ์กด ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ ๋„ ์ƒˆ๋กœ์šด ๊ตฌํ˜„์„ ์‰ฝ๊ฒŒ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Copy link
Author

Choose a reason for hiding this comment

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

ํ•ด๋‹น ํด๋ž˜์Šค๋ฅผ ํ†ตํ•ด ๋‘ ๊ฐ€์ง€๋ฅผ ํ•œ ๋ฒˆ์— ๋‹ฌ์„คํ•˜๋ ค๊ณ  ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค ๐Ÿ˜…
"๋žœ๋ค ํฌ์ธํŠธ๋ฅผ ๊ฐ–๋Š”", "Line์„ ์ƒ์„ฑ"ํ•œ๋‹ค

์ด๋Ÿฐ ์ƒํƒœ์—์„œ ๋‚˜์ค‘์— ์ด๋™์ด ์ง€์ • ๊ฐ€๋Šฅํ•œ Line์„ ๋งŒ๋“ค ์š”๊ตฌ์‚ฌํ•ญ์ด ์ƒ๊ธฐ์ง€ ์•Š์„๊นŒ? ๋ผ๋Š” ์ƒ๊ฐ์œผ๋กœ ์• ๋งค๋ชจํ˜ธํ•œ ํด๋ž˜์Šค๊ฐ€ ํƒ„์ƒํ–ˆ๋˜ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์€ ์ฑ…์ž„์„ ๋ถ„๋ฆฌ(RandomGenerator, Builder)ํ•˜์—ฌ ์ƒˆ๋กœ ๊ตฌ์„ฑํ–ˆ์œผ๋‹ˆ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

Copy link

@seok-2-o seok-2-o left a comment

Choose a reason for hiding this comment

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

์•ˆ๋…•ํ•˜์„ธ์š” ์ƒ์˜ค๋‹˜.
7๊ธฐ ๋ฆฌ๋ทฐ์–ด๋กœ ํ™œ๋™ํ–ˆ๋˜ ์ด์žฌ์„์ž…๋‹ˆ๋‹ค.

์˜ค๋žœ๋งŒ์— ์Šฌ๋ž™์— ๋“ค์–ด์˜จ๊ฒƒ ๊ฐ™์€๋ฐ ๋˜ ์šฐ์—ฐ์น˜ ์•Š๊ฒŒ ๋ฆฌ๋ทฐ ์š”์ฒญ์„ ๋ฐœ๊ฒฌํ•˜์—ฌ
์˜ค์ง€๋ž–์ผ ์ˆ˜ ์žˆ์ง€๋งŒ ๊ฐ„๋‹จํžˆ ์˜๊ฒฌ์„ ๋‚˜๋ˆ ๋ณด์•˜์Šต๋‹ˆ๋‹ค!

์ œ๊ฐ€ ๋งˆ์ง€๋ง‰๊นŒ์ง€ ํ•จ๊ป˜ํ•˜์ง€ ๋ชปํ•˜๋”๋ผ
์ƒ์˜ค๋‹˜์˜ ์—ด์ •์— ์กฐ๊ธˆ์ด๋‚˜๋งˆ ๋„์›€์ด ๋˜์—ˆ๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค!
๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

Comment on lines 25 to 26
.collect(Collectors.toList());
return new Lines(lines);

Choose a reason for hiding this comment

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

์ œ๊ฐ€ ์ž๋ฐ”๋ฅผ ์•ˆ์“ด์ง€ ์˜ค๋ž˜๋˜์„œ ๊ฐ€๋ฌผ ๊ฐ€๋ฌผํ•˜์ง€๋งŒ.... ์•„๋ž˜์™€ ๊ฐ™์ด ํ•œ๋ฒˆ์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์š”.

Suggested change
.collect(Collectors.toList());
return new Lines(lines);
.collect(collectingAndThen(toList(), Lines::new)

Comment on lines 16 to 18
if (name.length() > 5) {
throw new IllegalArgumentException("์ด๋ฆ„์€ 5์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
}

Choose a reason for hiding this comment

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

๋งค์ง ๋„˜๋ฒ„๊ฐ€ ์‚ฌ์šฉ๋˜์—ˆ๋„ค์š”.
ํŠนํžˆ๋‚˜ ์ด๋ฆ„ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ์ƒ๋Œ€์ ์œผ๋กœ ๋ณ€๊ฒฝ์ด ์‰ฝ๊ฒŒ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์š”์†Œ์ด๋‹ˆ๊นŒ
์ƒ์ˆ˜๋กœ ๊ด€๋ฆฌํ•œ๋‹ค๋ฉด ์žฅ์ ์ด ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”.

"์ด๋ฆ„์€ " + MAX_NAME_LENGTH +"์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค."

์œ„ ์ฒ˜๋Ÿผ ์˜ˆ์™ธ์—์„œ๋„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์‚ฌ์ด๋“œ ์ดํŽ™ํŠธ๋„ ์ค„์ผ ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”!

throw new IllegalArgumentException("์ ์ด ์—†์Šต๋‹ˆ๋‹ค.");
}

if (points.size() < 2) {

Choose a reason for hiding this comment

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

์—ฌ๊ธฐ๋„ ๋งค์ง๋„˜๋ฒ„๊ฐ€ ์‚ฌ์šฉ๋˜์—ˆ์–ด์š”.

๋‹ค๋งŒ ํ•ด๋‹น ๊ฐ’์€ ์‚ฌ๋‹ค๋ฆฌ ๊ฒŒ์ž„์—์„œ๋Š” ๋ถˆ๋ณ€์˜ ์ง„๋ฆฌ์— ๊ฐ€๊นŒ์šด ๊ฐ’์ด๋ผ ๊ตฌ์ง€ ์ƒ์ˆ˜๋กœ ์„ ์–ธํ•ด์•ผํ• ๊นŒ ๊ณ ๋ฏผ์ด ์žˆ๋„ค์š”.

์ƒ์ˆ˜๋กœ ์„ ์–ธํ–ˆ์„๋•Œ ์˜คํžˆ๋ ค ๋„ค์ด๋ฐ์„ ์ž˜ ํ•˜์ง€ ์•Š์•˜์„ ๊ฒฝ์šฐ ํ–‡๊ฐˆ๋ฆด ์ˆ˜ ์žˆ์ง€ ์žˆ์„๊นŒ ์‹ถ์–ด์„œ์š”!

์ƒ์˜ค๋‹˜ ์ƒ๊ฐ์ด ๊ถ๊ธˆํ•˜๋„ค์š”!

Copy link
Author

@sang5c sang5c Apr 23, 2024

Choose a reason for hiding this comment

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

์ฝ”๋“œ ์ผ๊ด€์„ฑ๊ณผ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€ (์ง์ „์˜ name.legnth()์™€ ๊ฐ™์€ ์ด์œ ๋กœ)์—์„œ ๋™์ผํ•œ ๊ฐ’์ด ์“ฐ์ผ ์ˆ˜ ์žˆ๋„๋ก ์ƒ์ˆ˜๋กœ ๋ถ„๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.
ํฌ์ธํŠธ์˜ ์ˆ˜๋Š” ์ฐธ์—ฌ์ž์˜ ์ˆ˜๋ฅผ ์˜๋ฏธํ•˜๊ธฐ์—, ๊ฒŒ์ž„์˜ ์„ค์ •์œผ๋กœ ๋น ์งˆ ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์ด๋ผ๋Š” ์ƒ๊ฐ๋„ ๋“œ๋„ค์š”!

์˜ˆ๋ฅผ ๋“ค์–ด "์ฐธ์—ฌ์ž๊ฐ€ ํ•œ๋ช…์ผ ์ˆ˜ ์žˆ๋‹ค" ๋˜๋Š” "์„ธ ๋ช… ์ด์ƒ์ด์–ด์•ผ ๊ฒŒ์ž„์ด ๊ฐ€๋Šฅํ•˜๋‹ค"๋“ฑ์œผ๋กœ ์ถ”๊ฐ€ ์š”๊ตฌ์‚ฌํ•ญ์ด ์ƒ๊ธด๋‹ค๋ฉด ์ฃผ์ž…๋ฐ›๋Š” ํ˜•ํƒœ๋กœ ๊ตฌ์„ฑํ•ด์•ผ ํ•œ๋‹ค๊ณ  ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค.
์ ์šฉํ•˜์ง€ ์•Š์€ ์ด์œ ๋Š” ๋ฌต์‹œ์ ์œผ๋กœ ์‚ฌ๋‹ค๋ฆฌ์˜ ์„ธ๋กœ ๋ผ์ธ์€ 2๊ฐœ ์ด์ƒ์ด๋ผ๋Š” ์•ฝ์†์ด ์กด์žฌํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ณ . 1๊ฐœ ๊ฐ€๋Šฅ ๋˜๋Š” 3๊ฐœ ์ด์ƒ์€ ์ผ๋ฐ˜์ ์ด์ง€ ์•Š์€ ์ผ€์ด์Šค๋ผ ํ˜„์žฌ ์ƒํƒœ(2๊ฐœ ์ด์ƒ)๋ฅผ ์œ ์ง€ํ•˜๋Š” ๋ฐฉํ–ฅ์œผ๋กœ ๊ฒฐ์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!

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

public class LineBuilder {

Choose a reason for hiding this comment

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

ํŒฉํ† ๋ฆฌ๋ฅผ ์จ์„œ ์–ป๊ณ ์ž ํ•˜๋Š” ์ด๋“์ด ๋ฌด์—‡์ธ๊ฐ€์š”? ๐Ÿค” ๐Ÿ’ญ

Comment on lines 13 to 22
public static Line buildWithRandomPoints(int count) {
return new LineBuilder().initRandomMoveablePoint()
.addRandomMoveablePoints(count - 2)
.build();
}

private Line build() {
points.add(lastPoint().createRightmost());
return new Line(points);
}

Choose a reason for hiding this comment

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

ํด๋ž˜์Šค์˜ ์ด๋ฆ„์ด ๋นŒ๋”์ธ๋ฐ ๋นŒ๋“œํ•จ์ˆ˜๊ฐ€ private ํ•˜๊ฒŒ ์„ ์–ธ๋˜๋ฉด ์‚ฌ์šฉํ• ๋•Œ ํ–‡๊ฐˆ๋ฆฌ์ง€ ์•Š์„๊นŒ์š”?
๐Ÿค”

Copy link
Author

@sang5c sang5c Apr 23, 2024

Choose a reason for hiding this comment

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

์ด์ „ ๋ฆฌ๋ทฐ์ธ #2120 (comment) ์— ๋Œ“๊ธ€์ด ์•ˆ๋‹ฌ๋ ค ์ด๊ณณ์— ํ•œ๋ฒˆ์— ๋‹ต๋ณ€๋“œ๋ฆฝ๋‹ˆ๋‹ค!

ํŒฉํ† ๋ฆฌ ์จ์„œ ์–ป๊ณ ์ž ํ•˜๋Š” ์ด๋“

์ตœ์ดˆ ์ž‘์„ฑ ์˜๋„๋Š” ํŒฉํ† ๋ฆฌ๋ฅผ ํ†ตํ•ด ์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ(manual) ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜, ๋žœ๋ค(auto)ํ•˜๊ฒŒ ์ƒ์„ฑํ•œ๋‹ค. ๋ฅผ ๋ชฉํ‘œ๋กœ ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค.

ํด๋ž˜์Šค์˜ ์ด๋ฆ„์ด ๋นŒ๋”์ธ๋ฐ build()๊ฐ€ private์ด ๋œ ์ด์œ 

ํ˜„์žฌ๋Š” ์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ƒ์„ฑ(manual)์— ๋Œ€ํ•œ ์š”๊ตฌ์‚ฌํ•ญ์ด ์—†์œผ๋‹ˆ ๋ง‰์•„์•ผ ํ•˜์ง€ ์•Š์„๊นŒ? ๋ผ๋Š” ์ƒ๊ฐ๊ณผ ๋‚˜์ค‘์— ์ง์ ‘ ๋ผ์ธ์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์š”๊ตฌ์‚ฌํ•ญ์ด ์ƒ๊ฒผ์„ ๋•Œ๋ฅผ ์œ„ํ•ด build()๋ฅผ ๋‘๊ณ  ์ด๋ฅผ public์œผ๋กœ ์—ด๋ฉด ๋˜์ง€ ์•Š์„๊นŒ? ๋ผ๋Š” ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์ƒ๊ฐ์ด ๊ฒฐํ•ฉ๋˜์–ด ์• ๋งคํ•œ ์ฝ”๋“œ๊ฐ€ ๋‚˜์™”์Šต๋‹ˆ๋‹ค ใ…Žใ…Ž

๊ฒฐ๊ตญ ๋นŒ๋”์™€ ์ œ๋„ˆ๋ ˆ์ดํ„ฐ์˜ ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ•˜๊ณ  build() ๋ฉ”์„œ๋“œ๋Š” public์œผ๋กœ ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค :)

Comment on lines 24 to 35
private LineBuilder addRandomMoveablePoints(int numberOfMiddlePoints) {
for (int i = 0; i < numberOfMiddlePoints; i++) {
Point point = lastPoint().createNext(RANDOM.nextBoolean());
points.add(point);
}
return this;
}

private LineBuilder initRandomMoveablePoint() {
points.add(Point.createLeftmost(RANDOM.nextBoolean()));
return this;
}

Choose a reason for hiding this comment

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

๋‘ ๋‹จ๊ณ„๋ฅผ ๋‚˜๋ˆˆ ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ด์š”!

์•„๋ž˜์™€๊ฐ™์ด ํ•œ๋‹จ๊ณ„๋กœ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด ๋” ํŽธ๋ฆฌํ•˜์ง€ ์•Š์„๊นŒ์š”? ๐Ÿค”

(์ œ๊ฐ€ ์ž๋ฐ”๋ฅผ ์˜ค๋žœ๋งŒ์— ์“ฐ๊ณ  + IDE์ด ํ™˜๊ฒฝ์ด ์•„๋‹ˆ๋ผ์„œ ๋ฌธ๋ฒ•์˜ค๋ฅ˜ ์–‘ํ•ด๋ถ€ํƒ๋“œ๋ฆด๊ฒŒ์š”)

private LineBuilder create(int count) {
Point current = Point.createLeftmost(RANDOM.nextBoolean())
potins.add(current)
for (int i = 0; i < count - 2; i++) {
     current = current.next()
     potins.add(current()
}
}

Copy link
Author

Choose a reason for hiding this comment

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

์ฒซ ๋ฒˆ์งธ ํฌ์ธํŠธ์˜ ์ถ”๊ฐ€ ๋ฐฉ์‹์ด ๋‹ค๋ฅด๋‹ค๋Š” ๊ฒƒ์„ ๋ช…์‹œ์ ์œผ๋กœ ๋‚˜ํƒ€๋‚ด๊ณ  ์‹ถ์—ˆ์Šต๋‹ˆ๋‹ค. ์ด์ „ ๋Œ“๊ธ€๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ builder ๋ถ„๋ฆฌ๋ฅผ ์ง„ํ–‰ํ–ˆ๊ณ  ๋กœ์ง์ด ํ•˜๋‚˜๋กœ ํ†ตํ•ฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

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

public class LineBuilder {

Choose a reason for hiding this comment

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

์ œ๊ฐ€ ์ƒ๊ฐํ•˜๋Š” ํŒฉํ† ๋ฆฌ์˜ ์žฅ์ ์€ ์•„๋ž˜ ์ •๋„์ธ๋ฐ ํ•ด๋‹น์‚ฌํ•ญ์ด ์—†๋Š”๊ฒƒ ๊ฐ™์•„์„œ์š” ๐Ÿค”

๊ฐ์ฒด ์ƒ์„ฑ์— ์กฐ๊ฑด์ด ์žˆ์„ ๋•Œ: ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์กฐ๊ฑด์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์ข…๋ฅ˜์˜ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ, ํŒฉํ† ๋ฆฌ ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜์—ฌ ์กฐ๊ฑด์— ๋”ฐ๋ผ ์ ์ ˆํ•œ ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ตฌํ˜„์„ ๋ณ€๊ฒฝํ•  ํ•„์š”๊ฐ€ ์žˆ์„ ๋•Œ: ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ ๊ตฌํ˜„ ํด๋ž˜์Šค ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์—ฌ, ์ถ”ํ›„ ๊ตฌํ˜„์„ ๋ณ€๊ฒฝํ•  ๋•Œ ๊ธฐ์กด ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ ๋„ ์ƒˆ๋กœ์šด ๊ตฌํ˜„์„ ์‰ฝ๊ฒŒ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

public class Line {
private final List<Point> points;

Line(List<Point> points) {

Choose a reason for hiding this comment

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

ํŒฉํ† ๋ฆฌ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด default ๋กœ ์„ ์–ธํ•˜์‹ ๊ฑธ๊นŒ์š”? ๐Ÿ‘
๊ทธ๋ ‡๋‹ค๋ฉด ํŒจํ‚ค์ง€ ์กฐ์ •์„ ์กฐ๊ธˆ ๋” ์ž˜ ํ•ด๋ณผ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ์š”?

Copy link
Author

Choose a reason for hiding this comment

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

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค
๋ฆฌ๋ทฐ ์ฃผ์‹  ๋‚ด์šฉ์„ ๊ณ ๋ฏผํ•ด๋ดค๋Š”๋ฐ์š”!
Line์„ ์ƒ์„ฑ ๋ฐฉ์‹(๋งจ ์ขŒ์ธก์€ ์ขŒ๋กœ ์ด๋™ ๋ถˆ๊ฐ€, ๋งจ ์šฐ์ธก์€ ์šฐ์ธก ์ด๋™ ๋ถˆ๊ฐ€)์—๋„ ๊ฐ•์ œ๊ฐ€ ํ•„์š”ํ•˜์—ฌ ์ง์ ‘ ์ƒ์„ฑ์ด ๋ถˆ๊ฐ€๋Šฅ(private ์ƒ์„ฑ์ž)ํ•˜๋„๋ก ๋งŒ๋“ค๊ณ  Builder๋ฅผ Line ๋‚ด๋ถ€๋กœ ์ด๋™ํ•˜๋Š” ํ˜•ํƒœ๋กœ ํ•ด๊ฒฐํ•ด ๋ดค์Šต๋‹ˆ๋‹ค.
(LineBuilder๋ฅผ ํ†ตํ•ด์•ผ๋งŒ ๋ผ์ธ ์ƒ์„ฑ์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ๊ตฌ์„ฑ)

Comment on lines +40 to +42
printPlayers(ladderGame.getPlayers());
printLines(ladderGame.getLines());
}

Choose a reason for hiding this comment

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

์š”๊ฑด ์ œ๊ฐ€ ์ˆ˜์—…๋“ค์—ˆ์„๋•Œ...๊ทธ๋ฆฌ๊ณ  ๋ฆฌ๋ทฐ์–ด๋กœํ™œ๋™ํ• ๋–„๋ถ€ํ„ฐ ๊ณ ๋ฏผ์ด๊ธดํ•œ๋ฐ
๋‘ ๋ฆฌ์ŠคํŠธ์— ์ˆœ์„œ์— ์˜์กดํ•˜๋Š” ๋ฐฉ์‹์€ ๋‘ ๋ฆฌ์ŠคํŠธ์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ ๋ฐ์ดํ„ฐ์˜ ์ผ๊ด€์„ฑ์„ ํ™•์ธํ•˜๋Š”๊ฒŒ ์–ด๋ ต์ง€ ์•Š์„๊นŒ ์ƒ๊ฐ์ด ๋“œ๋Š”๋ฐ

์ƒ์˜ค๋‹˜ ์ƒ๊ฐ์ด ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!

Copy link
Author

@sang5c sang5c Apr 23, 2024

Choose a reason for hiding this comment

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

์™œ ์ด๋ ‡๊ฒŒ ์งฐ์„๊นŒ ๋Œ์ด์ผœ๋ดค๋Š”๋ฐ ๊ธฐ์กด ์ฝ”๋“œ๋Š” API์™€ ํด๋ผ์ด์–ธํŠธ ๋ชจ๋‘๋ฅผ ์ € ํ˜ผ์ž ๊ฐœ๋ฐœํ•˜๋‹ค๋ณด๋‹ˆ ์•”์‹œ์ ์œผ๋กœ ๋ฐ˜ํ™˜ ์ˆœ์„œ์— ์˜๋ฏธ๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋„ค์š”!

๋ช…ํ™•ํ•œ๊ฒŒ ๋” ๋‚ซ๋‹ค๊ณ  ๋Š๊ปด์„œ ํฌ์ธํŠธ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ธ๋ฑ์Šค๋ฅผ ๊ฐ–๋„๋ก ๊ตฌ์„ฑ์„ ๋ฐ”๊ฟ”๋ดค์Šต๋‹ˆ๋‹ค.

๋Œ“๊ธ€์„ ๋‹ฌ๋ฉด์„œ ๋“  ์ƒ๊ฐ์€ ํ˜„์žฌ๋Š” ์•”์‹œ์ ์œผ๋กœ(์ƒ์„ฑ ์ˆœ์„œ์— ์˜ํ•ด) ํ”Œ๋ ˆ์ด์–ด์˜ ์ธ๋ฑ์Šค์™€ ํฌ์ธํŠธ(์„ธ๋กœ ๋ผ์ธ)์˜ ์ธ๋ฑ์Šค๊ฐ€ ๊ฒฐํ•ฉ๋œ ํ˜•ํƒœ์ด๋‹ค. ๋ผ๋Š” ์ƒ๊ฐ๋„ ๋“œ๋„ค์š”.

@sang5c
Copy link
Author

sang5c commented Apr 23, 2024

๋ฆฌ๋ทฐ ๋„ˆ๋ฌด ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ™‡
๋ง์”€ ์ฃผ์‹  ๋‚ด์šฉ๋“ค ๊ณ ๋ฏผํ•ด์„œ ๋‹ค์‹œ ์ ์šฉํ•ด ๋ดค์Šต๋‹ˆ๋‹ค!

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