Skip to content

Comments

[BE] ์ด๋™ํ›ˆ ๐Ÿ‘ฅ ์˜ค๋Š˜์˜ ์ง๊ฟ์€?#21

Open
move-hoon wants to merge 45 commits intoLeets-Official:mainfrom
move-hoon:hoonyworld
Open

[BE] ์ด๋™ํ›ˆ ๐Ÿ‘ฅ ์˜ค๋Š˜์˜ ์ง๊ฟ์€?#21
move-hoon wants to merge 45 commits intoLeets-Official:mainfrom
move-hoon:hoonyworld

Conversation

@move-hoon
Copy link
Member

@move-hoon move-hoon commented Apr 11, 2024

ํŒจํ‚ค์ง€ ๊ตฌ์กฐ

image

๋ฏธ์…˜ ์‹คํ–‰ ๊ฒฐ๊ณผ

์‹คํ–‰ ๊ฒฐ๊ณผ

image

์˜ˆ์™ธ ์ฒ˜๋ฆฌ

๋ฉค๋ฒ„ ์ด๋ฆ„์— ์˜์–ด๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” ๊ฒฝ์šฐ

image

์ตœ๋Œ€ ์ง ์ˆ˜๊ฐ€ ์ˆซ์ž๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ

image

์ตœ๋Œ€ ์ง ์ˆ˜๋Š” ์ด๋ฆ„์˜ ๊ฐฏ์ˆ˜๋ณด๋‹ค ํฐ ๊ฒฝ์šฐ

image

์žฌ์‹œ์ž‘ ์ž…๋ ฅ์ด y,n์ด ์•„๋‹Œ๊ฒฝ์šฐ

image

๊ธฐ๋Šฅ ๋ช…์„ธ์„œ

๐Ÿ‘ฅ ๋ฏธ์…˜ - ์˜ค๋Š˜์˜ ์ง๊ฟ์€?

โœ… ํ•ต์‹ฌ ๊ธฐ๋Šฅ

๋ชฉํ‘œ

๋‚˜์˜ ์ง๊ฟ์„ ์ •ํ•ด์ค„ ๋žœ๋ค ์ง๊ฟ ๋งค์นญ ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑ

โœ… 1์ฃผ์ฐจ ๋ฏธ์…˜ ๋ชฉํ‘œ

๊ณผ์ œ๋ฅผ ํ†ตํ•ด ์ƒ๊ฐํ•ด๋ณด๊ธฐ

  • ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์ฝ”๋“œ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์งค ์ˆ˜ ์žˆ๋Š”์ง€
  • ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์œ ์ง€ ๋ณด์ˆ˜๊ฐ€ ์‰ฌ์šด ์ฝ”๋“œ๊ฐ€ ๋  ์ˆ˜ ์žˆ๋Š”์ง€
  • ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด ๋ชฉํ‘œํ•˜๋Š” ๋ฐ”๊ฐ€ ๋ฌด์—‡์ด๊ณ  ์ด๋ฅผ ์–ด๋–ป๊ฒŒ ์ฝ”๋“œ๋กœ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋Š”์ง€

โœ… ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ ๋ชฉ๋ก

[ Domain ]

  • Member

  • ์ฐธ๊ฐ€์ž์˜ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์™€ ๊ด€๋ จ ๋กœ์ง์„ ๋‹ด๋‹น

  • ๋ฌธ์ž์—ด๋กœ๋œ ๋ฉค๋ฒ„๋“ค์„ ๋ฆฌ์ŠคํŠธ๋กœ ๋ถ„๋ฆฌํ•˜๊ณ , ์ด ๋ฉค๋ฒ„์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

[ Service ]

  • GroupService
  • ์ฐธ๊ฐ€์ž๋“ค์„ ๊ทธ๋ฃนํ™”ํ•˜๋Š” ๋กœ์ง์„ ๋‹ด๋‹น
  • ๋žœ๋ค ์ง๊ฟ์„ ์ถ”์ฒจํ•ฉ๋‹ˆ๋‹ค.

[ View ]

  • InputView

  • ๋ฉค๋ฒ„ ์ด๋ฆ„์„ ์ž…๋ ฅ๋ฐ›์Œ (,๋กœ ๊ตฌ๋ถ„)

  • ์ตœ๋Œ€ ์ง ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์Œ

  • ๋‹ค์‹œ ๊ตฌ์„ฑํ• ์ง€ ๋ง์ง€ ์ž…๋ ฅ๋ฐ›์Œ(y,n)

  • OutputView

  • ์ง ์ถ”์ฒœ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์คŒ(default, y)

  • ์ธ์‚ฌ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด์—ฌ์คŒ(n)

[ Controller ]

  • MatchingController
    ์ง๊ถ ์ถ”์ฒœ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋กœ์ง์„ ๊ตฌํ˜„

โœ… ์˜ˆ์™ธ ์ฒ˜๋ฆฌ - exception

๊ณตํ†ต

  • ์˜ˆ์™ธ ์ƒํ™ฉ ์‹œ ์—๋Ÿฌ ๋ฌธ๊ตฌ๋ฅผ ์ถœ๋ ฅ. ๋‹จ, ์—๋Ÿฌ ๋ฌธ๊ตฌ๋Š” "[ERROR]"๋กœ ์‹œ์ž‘

์ด๋ฆ„ ์ž…๋ ฅ

  • ์ด๋ฆ„์ด ํ•œ๊ธ€์ด ์•„๋‹ˆ๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ

์ตœ๋Œ€ ์ง์ˆ˜ ์ž…๋ ฅ

  • ์ตœ๋Œ€ ์ง ์ˆ˜๊ฐ€ ์ด๋ฆ„์˜ ๊ฐฏ์ˆ˜๋ณด๋‹ค ํฌ๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ

retry ์ž…๋ ฅ

  • y์™€ n ์ด์™ธ์˜ ์ˆซ์ž๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ

- ์œ ํšจํ•˜์ง€ ์•Š์€ ์ž…๋ ฅ์— ๋Œ€ํ•œ ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€
- IllegalArgumentException ๊ฐ์ฒด๋ฅผ ์ œ๊ณต
- controller์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ static ์ถ”๊ฐ€
- ArrayList์˜ ์ œ๋„ค๋ฆญ ํƒ€์ž…์„ Member ํด๋ž˜์Šค๋กœ ๋ณ€ํ™˜ํ•œ ๊ฒƒ์— ๋Œ€ํ•œ ์ˆ˜์ •
- ํ•„๋“œ ์—†์ด ๊ทธ๋ฃนํ•‘ ํ•˜๋Š” ์ž‘์—…๋งŒ ์ˆ˜ํ–‰ํ•˜๊ธฐ์— ์„œ๋น„์Šค ๋ ˆ์ด์–ด๋กœ ์˜ฎ๊ธฐ๋Š” ๊ฒƒ์ด ๋” ๋‚ซ๋‹ค๊ณ  ํŒ๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค.
- group ๋ฆฌ์ŠคํŠธ๋ฅผ ๋น„์šฐ๋ฉด groups ๋ฆฌ์ŠคํŠธ ๋‚ด์— ์ถ”๊ฐ€๋œ ํ•ด๋‹น ๋ฆฌ์ŠคํŠธ์˜ ๋‚ด์šฉ๋„ ํ•จ๊ป˜ ์‚ญ์ œ๋˜๊ธฐ์— ์ƒˆ๋กœ์šด ArrayList ์ธ์Šคํ„ด์Šค ํ• ๋‹น
- ๊ธฐ์กด์— memberCount๋ฅผ ๋ฆฌํ„ดํ•ด์„œ ๋ฆฌ์ŠคํŠธ ํฌ๊ธฐ๊ฐ€ ๊ณ ์ •๋˜๋Š” ํ˜„์ƒ์„ ํ•ด๊ฒฐ
- groups.add(new ArrayList<>(group)) ๋ถ€๋ถ„์ด ์ค‘์š”ํ•˜๋‹ค.
- ๊ฐ์ฒด๋ฅผ ๊ฒฐํ•ฉํ•  ์ˆ˜๋Š” ์—†๊ธฐ์— String์œผ๋กœ ํƒ€์ž…์„ ๋ณ€ํ™˜ํ•ด์•ผ ํ–ˆ๋‹ค.
@move-hoon move-hoon self-assigned this Apr 11, 2024
@move-hoon move-hoon requested review from leejuae and zzu-yaaa April 11, 2024 08:59
String getMessage();

T getException();
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

๐Ÿ‘


**retry ์ž…๋ ฅ**
- [x] y์™€ n ์ด์™ธ์˜ ์ˆซ์ž๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ

Copy link
Member

Choose a reason for hiding this comment

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

์ฒดํฌ๋ฆฌ์ŠคํŠธ๋ฅผ ํ†ตํ•ด TODO๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํŽธ์ด ์ •๋ง ์ข‹์€ ๊ฒƒ ๊ฐ™์•„์š”!

Copy link
Member

@taeseokyang taeseokyang left a comment

Choose a reason for hiding this comment

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

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค!


List<Member> membersOfList = Member.parseMembers(members);

boolean retry = true;
Copy link
Member

Choose a reason for hiding this comment

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

์ฒ˜์Œ ํ• ๋•Œ๋„ retry๋ผ๊ณ  ํ•˜๋Š”๋ฐ ์˜๋ฏธ๊ฐ€ ์ž˜ ์•ˆ๋งž๋Š”๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค. isDone๊ฐ™์€๊ฑด ์–ด๋–จ๊นŒ์š”? ๊ทธ๋Ÿฌ๋ฉด while(!isDone) ์ด๋ ‡๊ฒŒ ํ•ด์•ผํ•˜๋Š”๋ฐ ์•„์—ฐ ๋ˆ„๋‚˜๋Š” ์กฐ๊ฑด์œผ๋กœ !๋“ค์–ด๊ฐ€๋Š”๊ฒŒ ์‹ซ๋‹ค๊ณ  ํ•˜๋„ค์š”. ๊ทธ๋Ÿผ isContinue ๋กœ ํ•˜๋ฉด ๋œ๋‹ค๊ณ  ํ•ด์š”! booleanํƒ€์ž…์ด๋‹ˆ๊นŒ ๋ณ€์ˆ˜๋ช… ์•ž์— is๊ฐ€ ๋ถ™์œผ๋ฉด ๋” ์ฝ๊ธฐ ์‰ฌ์šธ๊ฑฐ ๊ฐ™์•„์š”

OutputView.printCompletionMessage();

OutputView.printCanYouRetry();
retry = InputView.readRetry();
Copy link
Member

Choose a reason for hiding this comment

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

readRetryOpinion ์€ ์–ด๋–จ๊นŒ์š”? ์žฌ์‹œ๋„์ž…๋ ฅ ์ด๋ผ๋Š” ๋œป์ด ํ•จ์ˆ˜์˜ ๊ธฐ๋Šฅ์„ ์ž˜ ์„ค๋ช…์•ˆํ•ด์ฃผ๋Š”๊ฑฐ ๊ฐ™์•„์š”

import java.util.List;

public class GroupService {
public List<List<Member>> generateRandomGroups(List<Member> memberList, int maximumGroupSize) {
Copy link
Member

Choose a reason for hiding this comment

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

GPT๊ฐ€ ๊ฐœ์„ ํ•œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค. ์ฐธ๊ณ ํ•˜์‹œ๋ฉด ์ข‹์„๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Collections.shuffle(memberList);

List<List<Member>> groups = new ArrayList<>();

int totalMembers = memberList.size();
int groupCount = (int) Math.ceil((double) totalMembers / maximumGroupSize);

for (int i = 0; i < groupCount; i++) {
    int fromIndex = i * maximumGroupSize;
    int toIndex = Math.min((i + 1) * maximumGroupSize, totalMembers);
    
    List<Member> subList = memberList.subList(fromIndex, toIndex);
    groups.add(new ArrayList<>(subList));
}

return groups;

try {
String input = kb.nextLine();
String[] members = input.split(",");
for (String member : members) {
Copy link
Member

Choose a reason for hiding this comment

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

๋ฌธ์ž์—ด ๋ถ„๋ฆฌํ•˜๊ธฐ ์ „์— ๊ฒ€์‚ฌํ•˜๋ฉด ๋ฐ˜๋ณต ํ•„์š”์—†์ด ํ•œ๋ฒˆ๋งŒ ํ•  ์ˆ˜ ์žˆ์„๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค

}
}

public static int readMaxGroup(String[] members) {
Copy link
Member

Choose a reason for hiding this comment

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

์ฝ๋Š”๋‹ค๋Š” ํ•จ์ˆ˜์ธ๋ฐ, ์•ˆ์—์„œ ์ถœ๋ ฅ๋„ ํ•˜๋„ค์š”! ๋ถ„๋ฆฌ ํ•  ์ˆ˜๋Š” ์—†์—ˆ์„๊นŒ์š”?

Copy link
Member

@ay-eonii ay-eonii left a comment

Choose a reason for hiding this comment

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

1์ฃผ์ฐจ ๋ฏธ์…˜ ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค๐Ÿ™Œ
MVC ํŒจํ„ด์ด ์ธ์ƒ๊นŠ๋„ค์š” ๐Ÿ˜Š๐Ÿ‘

import java.util.List;

public class MatchingController {
GroupService groupService = new GroupService();
Copy link
Member

Choose a reason for hiding this comment

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

default๋กœ ๋‘” ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

import java.util.Scanner;
import java.util.regex.Pattern;

public class InputView {
Copy link
Member

Choose a reason for hiding this comment

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

๋ชจ๋“  ๋ฉ”์„œ๋“œ๊ฐ€ static์ด๋„ค์š”. ๊ทธ๋Ÿผ InputView๋Š” ๊ฐ์ฒด์Šค๋Ÿฝ๊ฒŒ ์ผํ•˜๊ณ  ์žˆ๋‚˜์š”?

}

public static String[] readMember() {
OutputView.printStartMessage();
Copy link
Member

Choose a reason for hiding this comment

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

OutputView.printStartMessage()๊ฐ€ ๋ฉค๋ฒ„๋ฅผ ์ฝ๋Š” ๊ณผ์ •์ธ๊ฐ€์š”?
์ถ”๊ฐ€์ ์œผ๋กœ InputView๊ฐ€ OutputView๋ฅผ ์•„๋Š”๊ฒƒ์— ๋Œ€ํ•ด ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์„ธ์š”?

MatchingController controller = new MatchingController();
controller.run();
}
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

image

EOL ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด์š”

OutputView.printCanYouRetry();
retry = InputView.readRetry();

if (retry == true) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (retry == true) {
if (retry) {

๋น„๊ตํ•œ ์ด์œ ๊ฐ€ ์žˆ๋‚˜์š”?

return members;
}

public static int memberNumber(List<Member> members) {
Copy link
Member

Choose a reason for hiding this comment

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

static ์ธ ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•˜๋„ค์š”

Comment on lines +77 to +80
if (c == 'y') {
return true;
} else if (c == 'n') {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

yellow๋ฅผ ์ž…๋ ฅํ•ด๋„ ์žฌ๋งค์นญํ•ด์ค„ ๊ฒƒ ๊ฐ™์•„์š”

int maximumGroupSize = kb.nextInt();
kb.nextLine();

checkDataValidity(memberCount, maximumGroupSize);
Copy link
Member

Choose a reason for hiding this comment

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

์ตœ๋Œ€ ์ง ์ˆ˜๋Š” ๋ฉค๋ฒ„์ˆ˜๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์•„์•ผํ•œ๋‹ค

View๊ฐ€ ์ตœ๋Œ€ ์ง ์ˆ˜์— ๋Œ€ํ•œ ์กฐ๊ฑด๊ณผ ๋ฉค๋ฒ„ ์ˆ˜๋ฅผ ์•Œ๊ณ  ์žˆ๋Š” ๊ฑฐ ๊ฐ™์•„์š”. InputView๋Š” ๊ฒ€์ฆ์„ ํ•˜๋Š” ๊ฐ์ฒด์ธ๊ฐ€์š”?

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.

4 participants