Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
75e5b9a
docs: ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ ๋ชฉ๋ก ์ž‘์„ฑ
move-hoon Apr 11, 2024
c4c7968
refactor(LeetsMateApplication): ์„ ์–ธ๋œ ๋ฉ”์„œ๋“œ ๋ถ„๋ฆฌ
move-hoon Apr 11, 2024
2babb5e
feat(Member): ๋ฌธ์ž์—ด๋กœ๋œ ๋ฉค๋ฒ„๋“ค์„ ๋ฆฌ์ŠคํŠธ๋กœ ๋ถ„๋ฆฌํ•˜๊ณ , ์ด ๋ฉค๋ฒ„์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋„๋ฉ”์ธ ์ƒ์„ฑ
move-hoon Apr 11, 2024
d137178
feat(Group): ๋žœ๋ค ์ง๊ฟ ์ถ”์ฒœ์„ ๋‹ด๋‹นํ•˜๋Š” ๋„๋ฉ”์ธ ์ƒ์„ฑ
move-hoon Apr 11, 2024
4cf6b38
feat(InputVIew): ๋ฉค๋ฒ„ ์ด๋ฆ„, ์ตœ๋Œ€ ์ง ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” ๋ทฐ ์ƒ์„ฑ
move-hoon Apr 11, 2024
1a91a77
feat(OutputVIew): ๊ฒฐ๊ณผ๋ฅผ ํ”„๋ฆฐํŠธํ•˜๋Š” ๋ทฐ ์ƒ์„ฑ
move-hoon Apr 11, 2024
a9efde8
feat(MatchingController): ์ง๊ถ ์ถ”์ฒœ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋กœ์ง์„ ๋‹ด๋‹นํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ ์ƒ์„ฑ
move-hoon Apr 11, 2024
7f4274b
test(LeetsMateApplicationTests): ํ…Œ์ŠคํŠธ ๋ถ„๋ฆฌ
move-hoon Apr 11, 2024
79a2f14
feat(InputView): ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
move-hoon Apr 11, 2024
a10611d
test(InputViewTests): ํ…Œ์ŠคํŠธ ๋กœ์ง ๋ถ„๋ฆฌ
move-hoon Apr 11, 2024
5c91465
test(MemberTests): ํ…Œ์ŠคํŠธ ๋กœ์ง ๋ถ„๋ฆฌ
move-hoon Apr 11, 2024
12c659e
feat(ExceptionType): ์˜ˆ์™ธ ํƒ€์ž…๋“ค์„ ํ‘œ์ค€ํ™”๋œ ๋ฐฉ์‹์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
move-hoon Apr 11, 2024
f168091
feat(IllegalArgumentExceptionType): ExceptionType ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•œ ์—ด๊ฑฐํ˜• ์ƒ์„ฑ
move-hoon Apr 11, 2024
e67a4a2
feat(OutputView): ์‹œ์ž‘ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
move-hoon Apr 11, 2024
91094ac
feat(IllegalArgumentExceptionType): ์ƒ์ˆ˜ ์ถ”๊ฐ€
move-hoon Apr 11, 2024
880f008
chore(LeetsMateApplication): ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” import๋ฌธ ์‚ญ์ œ
move-hoon Apr 11, 2024
1ed6286
refactor(OutputView): static ํ‚ค์›Œ๋“œ ์ถ”๊ฐ€
move-hoon Apr 11, 2024
1d5e516
feat(MatchingController): ์ถœ๋ ฅ๋ฉ”์‹œ์ง€, ๋ฉค๋ฒ„์˜ ์ด๋ฆ„ ์ž…๋ ฅ๋ฐ›๋Š” ๊ธฐ๋Šฅ ์ปจํŠธ๋กค๋Ÿฌ์— ๊ตฌํ˜„
move-hoon Apr 11, 2024
0bf22e9
feat(InputView): ๋ฉค๋ฒ„ ์ด๋ฆ„ ์ž…๋ ฅ, ์ตœ๋Œ€ ์ง ์ˆ˜ ์ž…๋ ฅ ๊ธฐ๋Šฅ ๋ฐ ๊ฒ€์ฆ ๋กœ์ง ๊ตฌํ˜„
move-hoon Apr 11, 2024
f665a22
feat(OutputView): ์ตœ๋Œ€ ์ง์ˆ˜ ์ž…๋ ฅ ๋ฉ˜ํŠธ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
move-hoon Apr 11, 2024
e42ab3d
refactor(InputView): ์ตœ๋Œ€ ์ง์ˆ˜๋ฅผ ์ž…๋ ฅํ•  ๋•Œ ์ˆซ์ž๊ฐ€ ์•„๋‹ˆ๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ
move-hoon Apr 11, 2024
c3929f0
refactor(MatchingController): InputView ๋ณ€๋™์‚ฌํ•ญ์— ๋Œ€ํ•œ ๋ฆฌํŒฉํ† ๋ง
move-hoon Apr 11, 2024
da4b742
feat(Member): ๋„๋ฉ”์ธ ๊ตฌํ˜„
move-hoon Apr 11, 2024
615d27d
test(MemberTests): ํƒ€์ž… ๋ณ€ํ™˜์— ์˜ํ•œ์— ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ •
move-hoon Apr 11, 2024
ec960d5
remove(Group): Group ๋„๋ฉ”์ธ์„ ์ œ๊ฑฐ
move-hoon Apr 11, 2024
a4bb9fd
feat(GroupService): GroupService ์ƒ์„ฑ
move-hoon Apr 11, 2024
d31a0a8
feat(GroupService): ์ตœ๋Œ€ ์ง์ˆ˜๋งŒํผ Groupingํ•˜๋Š” ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
move-hoon Apr 11, 2024
55c2bce
refactor(InputView): ๋ฌธ์ œ ์˜ˆ์‹œ์— ๋งž๊ฒŒ ๊ฐœํ–‰ ์ถ”๊ฐ€
move-hoon Apr 11, 2024
5ce6071
fix(GroupService): groups์— add๋œ group์˜ ๋‚ด์šฉ์ด ๋ชจ๋‘ ์ง€์›Œ์ง€๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
move-hoon Apr 11, 2024
35cbe6a
refactor(InputView): ๊ฐœํ–‰ ์‚ญ์ œ
move-hoon Apr 11, 2024
1df36fd
fix(InputView): maximumGroupSize๋ฅผ ๋ฆฌํ„ดํ•˜๋„๋ก ๋ณ€๊ฒฝ
move-hoon Apr 11, 2024
a4a0235
refactor(GroupService): clear()๋กœ group ๋ฆฌ์ŠคํŠธ ๋น„์šฐ๊ธฐ
move-hoon Apr 11, 2024
539d294
feat(OutputView): Member ๊ฐ์ฒด๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ String.join ๋„์ž…
move-hoon Apr 11, 2024
21ace85
feat(OutputView): ์ถ”์ฒจ ์™„๋ฃŒ ๋ฉ”์„ธ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
move-hoon Apr 11, 2024
3ac6f4e
docs: README ์—…๋ฐ์ดํŠธ
move-hoon Apr 11, 2024
b6f2158
feat(IllegalArgumentExceptionType): retry ์‹œ ์ž˜๋ชป๋œ ์ž…๋ ฅ ์—๋Ÿฌ ์ƒ์ˆ˜ ์ถ”๊ฐ€
move-hoon Apr 11, 2024
7199cf8
feat(InputView): retry๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
move-hoon Apr 11, 2024
3e116b7
feat(OutputView): retry ์—ฌ๋ถ€๋ฅผ ๋ฌป๋Š” ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ
move-hoon Apr 11, 2024
f4cd2e5
feat(OutputView): retry๋ฅผ ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ์— ํ•ด๋‹นํ•˜๋Š” ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
move-hoon Apr 11, 2024
31a6e40
chore(GroupService, InputView, Member): ์ฃผ์„ ์‚ญ์ œ
move-hoon Apr 11, 2024
2d883e5
feat(OutputView): ๋ผ์ธ์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์„œ๋“œ ์ƒ์„ฑ
move-hoon Apr 11, 2024
fcedf0c
feat(IllegalArgumentExceptionType): retry ์ž…๋ ฅ ์‹œ y,n ์ œ์™ธ ์ž…๋ ฅ ์—๋Ÿฌ ์ƒ์ˆ˜ ์ถ”๊ฐ€
move-hoon Apr 11, 2024
df1c4f9
feat(MatchingController): ์ปจํŠธ๋กค๋Ÿฌ ๊ตฌํ˜„
move-hoon Apr 11, 2024
e22276c
refactor(InputView): ์˜์–ด+ํ•œ๊ธ€ ํ˜ผํ•ฉ์„ ์žก์ง€ ๋ชปํ•˜๋Š” ๋ถ€๋ถ„ ์ˆ˜์ •
move-hoon Apr 11, 2024
7356307
docs: README ์—…๋ฐ์ดํŠธ
move-hoon Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Leets ๋ฏธ์…˜ 1์ฃผ์ฐจ

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

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

**๋ชฉํ‘œ**

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

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

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

### โœ… ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ ๋ชฉ๋ก
**[ Domain ]**
-

- [x] **Member**

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

**[ Service ]**
-

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

**[ View ]**
-

- [x] **InputView**

- ๋ฉค๋ฒ„ ์ด๋ฆ„์„ ์ž…๋ ฅ๋ฐ›์Œ (,๋กœ ๊ตฌ๋ถ„)
- ์ตœ๋Œ€ ์ง ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์Œ
- ๋‹ค์‹œ ๊ตฌ์„ฑํ• ์ง€ ๋ง์ง€ ์ž…๋ ฅ๋ฐ›์Œ(y,n)

- [x] **OutputView**
- ์ง ์ถ”์ฒœ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์คŒ(default, y)
- ์ธ์‚ฌ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด์—ฌ์คŒ(n)

**[ Controller ]**
-

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

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

********๊ณตํ†ต********

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

---

**์ด๋ฆ„ ์ž…๋ ฅ**

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

---

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

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

**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๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํŽธ์ด ์ •๋ง ์ข‹์€ ๊ฒƒ ๊ฐ™์•„์š”!


38 changes: 3 additions & 35 deletions src/main/java/leets/leets_mate/LeetsMateApplication.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,10 @@
package leets.leets_mate;

import java.util.*;
import leets.leets_mate.controller.MatchingController;

public class LeetsMateApplication {

// ๋™์ž‘ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public void run() {
}

// ๋ฌธ์ž์—ด๋กœ๋œ ๋ฉค๋ฒ„๋“ค์„ ๋ฆฌ์ŠคํŠธ๋กœ ๋ถ„๋ฆฌํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public List<String> parseMembers(String members) {
return new ArrayList<>();
}

// ์ด ๋ฉค๋ฒ„์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
public int memberNumber(List<String> members) {
return 0;
}

// ๋ฉค๋ฒ„ ๋ฌธ์ž์—ด์— ์˜์–ด๊ฐ€ ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์˜์–ด๊ฐ€ ์žˆ๋‹ค๋ฉด ์˜ˆ์™ธ ์ถœ๋ ฅ
public void checkHasNoEnglish(String members) {
}

// ๋ฉค๋ฒ„์ˆ˜์™€ ์ตœ๋Œ€ ์ง์ˆ˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์œ ํšจํ•œ์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. ์œ ํšจํ•˜์ง€ ์•Š๋‹ค๋ฉด ์˜ˆ์™ธ ์ถœ๋ ฅ
public void checkDataValidity(int memberCount, int maximumGroupSize) {
}

// ๋žœ๋ค ์ง๊ฟ ์ถ”์ฒจํ•˜๋Š” ํ•จ์ˆ˜ ์ž…๋‹ˆ๋‹ค.
public List<List<String>> generateRandomGroups(List<String> memberList, int maximumGroupSize) {
return new ArrayList<>();
}

// ๊ฒฐ๊ณผ๋ฅผ ํ”„๋ฆฐํŠธ ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
public void printResult(List<List<String>> result) {
}

public static void main(String[] args) {
LeetsMateApplication app = new LeetsMateApplication();
app.run();
MatchingController controller = new MatchingController();
controller.run();
}
}
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 ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด์š”

36 changes: 36 additions & 0 deletions src/main/java/leets/leets_mate/controller/MatchingController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package leets.leets_mate.controller;

import leets.leets_mate.domain.Member;
import leets.leets_mate.service.GroupService;
import leets.leets_mate.view.InputView;
import leets.leets_mate.view.OutputView;

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๋กœ ๋‘” ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?


public void run() {
String[] members = InputView.readMember();
int maxGroupSize = InputView.readMaxGroup(members);

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๊ฐ€ ๋ถ™์œผ๋ฉด ๋” ์ฝ๊ธฐ ์‰ฌ์šธ๊ฑฐ ๊ฐ™์•„์š”

while (retry) {
List<List<Member>> groupsOfList = groupService.generateRandomGroups(membersOfList, maxGroupSize);

OutputView.printResult(groupsOfList);
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 ์€ ์–ด๋–จ๊นŒ์š”? ์žฌ์‹œ๋„์ž…๋ ฅ ์ด๋ผ๋Š” ๋œป์ด ํ•จ์ˆ˜์˜ ๊ธฐ๋Šฅ์„ ์ž˜ ์„ค๋ช…์•ˆํ•ด์ฃผ๋Š”๊ฑฐ ๊ฐ™์•„์š”


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) {

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

OutputView.printLine();
}
}

OutputView.printDontWantRetry();
}
}
29 changes: 29 additions & 0 deletions src/main/java/leets/leets_mate/domain/Member.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package leets.leets_mate.domain;

import java.util.ArrayList;
import java.util.List;

public class Member {
private String name;

public Member(String name) {
this.name = name;
}

public static List<Member> parseMembers(String[] memberName) {
List<Member> members = new ArrayList<>();
for (String name : memberName) {
members.add(new Member(name));
}

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 ์ธ ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•˜๋„ค์š”

return members.size();
}

public String getName() {
return name;
}
}
32 changes: 32 additions & 0 deletions src/main/java/leets/leets_mate/service/GroupService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package leets.leets_mate.service;

import leets.leets_mate.domain.Member;

import java.util.ArrayList;
import java.util.Collections;
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;

Collections.shuffle(memberList);

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

for (Member member : memberList) {
group.add(member);

if (group.size() == maximumGroupSize) {
groups.add(new ArrayList<>(group));
group.clear();
}
}

// ํ˜„์žฌ๋กœ์จ๋Š” ๋นˆ ๊ทธ๋ฃน์ด ์ถ”๊ฐ€๋  ๊ฐ€๋Šฅ์„ฑ์ด ๋ณด์ด์ง€ ์•Š๊ธดํ•˜๋‚˜, ํ˜น์‹œ ๋ชจ๋ฅผ ๋นˆ ๊ทธ๋ฃน ์ถ”๊ฐ€ ๋ฐฉ์ง€
if (!group.isEmpty()) {
groups.add(group);
}

return groups;
}
}
88 changes: 88 additions & 0 deletions src/main/java/leets/leets_mate/view/InputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package leets.leets_mate.view;

import leets.leets_mate.view.exception.IllegalArgumentExceptionType;

import java.util.InputMismatchException;
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๋Š” ๊ฐ์ฒด์Šค๋Ÿฝ๊ฒŒ ์ผํ•˜๊ณ  ์žˆ๋‚˜์š”?

private static final Scanner kb = new Scanner(System.in);

private InputView() {
}

public static InputView create() {
return new 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๋ฅผ ์•„๋Š”๊ฒƒ์— ๋Œ€ํ•ด ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์„ธ์š”?

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.

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

checkHasNoEnglish(member);
}
return members;
}
catch (IllegalArgumentException e) {
System.out.println(e.getMessage()); // ์ถ”ํ›„ ์ด๋ถ€๋ถ„์€ enum์œผ๋กœ ๋™์•„๋ฆฌ ๋ถ€์›๋ฅผ ๊ด€๋ฆฌํ–ˆ์„ ๋•Œ ์—†๋Š” ๋™์•„๋ฆฌ ๋ถ€์›์„ ์ž…๋ ฅํ•˜๋ฉด ์—๋Ÿฌ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ๋„ ํ•˜๋„๋ก ๊ตฌํ˜„
return readMember();
}
}

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.

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

OutputView.printMaxGroup();
try {
int memberCount = members.length;
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๋Š” ๊ฒ€์ฆ์„ ํ•˜๋Š” ๊ฐ์ฒด์ธ๊ฐ€์š”?


System.out.println();
return maximumGroupSize;
} catch (InputMismatchException e) {
System.out.println(IllegalArgumentExceptionType.INVALID_MAX_GROUP.getMessage());
kb.nextLine();
return readMaxGroup((members));
} catch (IllegalArgumentException e){
System.out.println(e.getMessage());
return readMaxGroup(members);
}
}

public static void checkHasNoEnglish(String member) {
// Character.isAlphabetic()์€ ์˜์–ด์ธ์ง€ ๊ตฌ๋ณ„ํ•ด์ฃผ๋Š”๊ฒŒ ์•„๋‹Œ ์ˆซ์ž์™€ ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•ด์ค€๋‹ค!
// for(char c : member.toCharArray()) {
// if (Character.isAlphabetic(c)) {
// throw IllegalArgumentExceptionType.INVALID_NAMING.getException();
// }
// }
if (Pattern.matches(".*[a-zA-Z]+.*", member)) {
throw IllegalArgumentExceptionType.INVALID_NAMING.getException();
}
}

public static void checkDataValidity(int memberCount, int maximumGroupSize) {
if (memberCount < maximumGroupSize) {
throw IllegalArgumentExceptionType.GROUP_SIZE_EXCEEDS_MEMBER_COUNT.getException();
}
}

public static boolean readRetry() {
try {
char c = kb.next().charAt(0);
if (c == 'y') {
return true;
} else if (c == 'n') {
return false;
Comment on lines +77 to +80
Copy link
Member

Choose a reason for hiding this comment

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

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

} else
throw IllegalArgumentExceptionType.INVALID_RETRY_INPUT.getException();
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
return readRetry();
}
}
}
49 changes: 49 additions & 0 deletions src/main/java/leets/leets_mate/view/OutputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package leets.leets_mate.view;

import leets.leets_mate.domain.Member;

import java.util.List;
import java.util.stream.Collectors;

public class OutputView {
public static void printStartMessage() {
System.out.println("[Leets ์˜ค๋Š˜์˜ ์ง์—๊ฒŒ]๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.");
System.out.println();
System.out.println("๋ฉค๋ฒ„์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”. (, ๋กœ ๊ตฌ๋ถ„)");
}

public static void printMaxGroup() {
System.out.println();
System.out.println("์ตœ๋Œ€ ์ง ์ˆ˜๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.");
}

public static void printResult(List<List<Member>> result) {
System.out.println("์˜ค๋Š˜์˜ ์ง ์ถ”์ฒœ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.");
for (List<Member> group : result) {

List<String> memberNames = group.stream()
.map(Member::getName)
.collect(Collectors.toList());
String groupResult = String.join(" | ", memberNames);

System.out.println("[ " + groupResult + " ]");
}
}

public static void printCompletionMessage() {
System.out.println();
System.out.println("์ถ”์ฒœ์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.");
}

public static void printCanYouRetry() {
System.out.print("๋‹ค์‹œ ๊ตฌ์„ฑํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (y or n): ");
}

public static void printLine() {
System.out.println("--------------------------------");
}

public static void printDontWantRetry() {
System.out.println("์ž๋ฆฌ๋ฅผ ์ด๋™ํ•ด ์„œ๋กœ์—๊ฒŒ ์ธ์‚ฌํ•ด์ฃผ์„ธ์š”.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package leets.leets_mate.view.exception;

public interface ExceptionType<T> {
String getMessage();

T getException();
}
Copy link
Member

Choose a reason for hiding this comment

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

๐Ÿ‘

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package leets.leets_mate.view.exception;

public enum IllegalArgumentExceptionType implements ExceptionType<IllegalArgumentException> {

INVALID_NAMING("[ERROR] ์ด๋ฆ„์€ ํ•œ๊ธ€๋กœ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค"),
GROUP_SIZE_EXCEEDS_MEMBER_COUNT("[ERROR] ์ตœ๋Œ€ ์ง ์ˆ˜๋Š” ์ด๋ฆ„์˜ ๊ฐฏ์ˆ˜๋ณด๋‹ค ํด ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."),
INVALID_MAX_GROUP("[ERROR] ์ตœ๋Œ€ ์ง์ˆ˜๋Š” ์ˆซ์ž๋กœ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค"),
INVALID_RETRY_INPUT("[ERROR] y์™€ n๋งŒ ์ž…๋ ฅ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.");

private final String message;

IllegalArgumentExceptionType(String message) {
this.message = message;
}

@Override
public String getMessage() {
return message;
}

@Override
public IllegalArgumentException getException() {
return new IllegalArgumentException(getMessage());
}
}
Loading