-
Notifications
You must be signed in to change notification settings - Fork 14
[BE] ํ์นํ ๐ฅ ์ค๋์ ์ง๊ฟ์? #22
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -6,33 +6,87 @@ public class LeetsMateApplication { | |
|
|
||
| // ๋์ ํจ์์ ๋๋ค. | ||
| public void run() { | ||
| Scanner scanner=new Scanner(System.in); | ||
| try{ | ||
| System.out.println("๋๊ตฌ๋๊ตฌ์์ด?"); | ||
| String leetsMember=scanner.nextLine(); | ||
| checkHasNoEnglish(leetsMember); | ||
|
|
||
| List<String> membersList=parseMembers((leetsMember)); | ||
|
Member
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. (())๊ดํธ ์ค๋ณต ์๋๊ฑฐ ๊ฐ์์! |
||
|
|
||
| System.out.println("๋ช๋ช ์ฉํ ๋?"); | ||
| int groupNum=scanner.nextInt(); | ||
| checkDataValidity(membersList.size(),groupNum); | ||
|
|
||
| List<List<String>> leetsGroup=generateRandomGroups(membersList,groupNum); | ||
|
|
||
| System.out.println("๊ฒฐ๊ณผ์ผ."); | ||
| printResult(leetsGroup); | ||
|
|
||
| while(true){ | ||
| System.out.println("๋ง์์ ์๋ค์ด?(y/n)"); | ||
| String answer=scanner.next(); | ||
|
Comment on lines
+27
to
+28
Member
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(answer.equalsIgnoreCase("y")){ | ||
| leetsGroup=generateRandomGroups(membersList,groupNum); | ||
| printResult(leetsGroup); | ||
| } | ||
| else if(answer.equalsIgnoreCase("n")){ | ||
| break; | ||
| } | ||
| } | ||
|
Comment on lines
+26
to
+36
Member
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. ์๋ฌธ y์ n ์ด์ธ์ ๊ฐ์ด ๋ค์ด์์๋์ ์์ธ์ฒ๋ฆฌ๊ฐ ์๋๊ฒ ๊ฐ์๋ฐ, ์ข๋ ๊ตฌ์ฒด์ ์ธ ์๋ฌ ๋ก์ง์ ์ถ๊ฐํ๋๊ฒ ์ด๋จ๊น์? |
||
| }catch(IllegalArgumentException e){ | ||
| System.out.println("[ERROR]"+ e.getMessage()); | ||
| run(); | ||
| }finally{ | ||
| scanner.close(); | ||
| } | ||
|
Comment on lines
+37
to
+42
Member
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. e๋ก ๋๊ฒจ์ฃผ๋ ๊ฒ๋ณด๋ค๋ ๊ตฌ์ฒด์ ์ธ ์ผ์ด์ค์ ๋ฐ๋ผ์ ์๋ฌ๋ฉ์์ง๋ฅผ ๋ฃ๋๊ฒ์ด ์ข๋ ์ข์๊ฒ ๊ฐ์์ |
||
| } | ||
|
Comment on lines
+26
to
43
Member
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. ๋ฉ์๋๋ก ๋ฐ๋ก ๋ถ๋ฆฌํ๋๊ฒ ๋ ์ข์๋ณด์ ๋๋ค |
||
|
|
||
| // ๋ฌธ์์ด๋ก๋ ๋ฉค๋ฒ๋ค์ ๋ฆฌ์คํธ๋ก ๋ถ๋ฆฌํ๋ ํจ์์ ๋๋ค. | ||
| public List<String> parseMembers(String members) { | ||
| return new ArrayList<>(); | ||
| List<String> memberList=new ArrayList<>(); | ||
| String[] divide=members.split(","); | ||
|
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. ์ฌ๋1, ์ฌ๋2, (๋์ด์ฐ๊ธฐ 2๊ฐ) ์ฌ๋3,์ฌ๋4, ์ฌ๋5 |
||
| for(String member:divide){ | ||
| memberList.add(member); | ||
| } | ||
| return memberList; | ||
| } | ||
|
|
||
| // ์ด ๋ฉค๋ฒ์๋ฅผ ๋ฐํํฉ๋๋ค. | ||
| public int memberNumber(List<String> members) { | ||
| return 0; | ||
| return members.size(); | ||
| } | ||
|
|
||
| // ๋ฉค๋ฒ ๋ฌธ์์ด์ ์์ด๊ฐ ์๋์ง ๊ฒ์ฌํฉ๋๋ค. ์์ด๊ฐ ์๋ค๋ฉด ์์ธ ์ถ๋ ฅ | ||
| public void checkHasNoEnglish(String members) { | ||
| if(members.matches(".*[a-zA-Z].*")){ | ||
| throw new IllegalArgumentException("์์ด๊ฐ ๋ค์ด๊ฐ๋ฉด ์๋๋ค."); | ||
| } | ||
|
Comment on lines
+62
to
+64
Member
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. ๋น ๊ฐ์ด ๋ค์ด๊ฐ ๊ฒฝ์ฐ๋ ์ถ๊ฐํ๋๊ฒ์ด ์ด๋จ๊น์? |
||
| } | ||
|
|
||
| // ๋ฉค๋ฒ์์ ์ต๋ ์ง์ ๋ฐ์ดํฐ๊ฐ ์ ํจํ์ง ๊ฒ์ฌํ๋ ํจ์์ ๋๋ค. ์ ํจํ์ง ์๋ค๋ฉด ์์ธ ์ถ๋ ฅ | ||
| public void checkDataValidity(int memberCount, int maximumGroupSize) { | ||
| if(memberCount<=0||maximumGroupSize<=0||maximumGroupSize>memberCount){ | ||
| throw new IllegalArgumentException(("๋ฉค๋ฒ์์ ์ต๋์ง์ ๋ฐ์ดํฐ๊ฐ ์ ํจํ์ง ์์ต๋๋ค.")); | ||
| } | ||
| } | ||
|
|
||
| // ๋๋ค ์ง๊ฟ ์ถ์ฒจํ๋ ํจ์ ์ ๋๋ค. | ||
| public List<List<String>> generateRandomGroups(List<String> memberList, int maximumGroupSize) { | ||
| return new ArrayList<>(); | ||
| List<String> afterMembers = new ArrayList<>(memberList); | ||
| Collections.shuffle(afterMembers); | ||
| List<List<String>> groups = new ArrayList<>(); | ||
|
Comment on lines
+76
to
+78
Member
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. List๋ฅผ ์ฌ๋ฌ๋ฒ ์ ์ธํ๋๊ฒ๋ณด๋ค ๋ถํ์ํ ์ฝ๋๋ฅผ ์ค์ด๋๊ฒ ์ด๋จ๊น์? groups๋ง ์ฌ์ฉํ๋ฉด ์ข๋ ๊ฐ๊ฒฐํ ์ฝ๋๊ฐ ๋ ๊ฑฐ๊ฐ์์! |
||
| for(int i=0;i<afterMembers.size();i+=maximumGroupSize){ | ||
| groups.add(afterMembers.subList(i,Math.min(i+maximumGroupSize,afterMembers.size()))); | ||
| } | ||
|
Comment on lines
+79
to
+81
Member
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. ์ด๋ฐ ๋ฐฉ๋ฒ๋ ์๊ตฐ์ ๋ฐฐ์๊ฐ๋๋ค |
||
| return groups; | ||
| } | ||
|
|
||
| // ๊ฒฐ๊ณผ๋ฅผ ํ๋ฆฐํธ ํ๋ ํจ์์ ๋๋ค. | ||
| public void printResult(List<List<String>> result) { | ||
| for(int i=0;i<result.size();i++){ | ||
| System.out.println(result.get(i)); | ||
| } | ||
|
Comment on lines
+87
to
+89
Member
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.
|
||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
|
|
||
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.
์๊ตฌ์ฌํญ์ ๋ง๊ฒ ์์ฑํด์ฃผ์๋ฉด ๋ ์ข์๊ฒ ๊ฐ์์!