[BE] ํ์นํ ๐ฅ ์ค๋์ ์ง๊ฟ์?#22
[BE] ํ์นํ ๐ฅ ์ค๋์ ์ง๊ฟ์?#221winhyun wants to merge 1 commit intoLeets-Official:mainfrom
Conversation
| public void run() { | ||
| Scanner scanner=new Scanner(System.in); | ||
| try{ | ||
| System.out.println("๋๊ตฌ๋๊ตฌ์์ด?"); |
There was a problem hiding this comment.
์๊ตฌ์ฌํญ์ ๋ง๊ฒ ์์ฑํด์ฃผ์๋ฉด ๋ ์ข์๊ฒ ๊ฐ์์!
| while(true){ | ||
| System.out.println("๋ง์์ ์๋ค์ด?(y/n)"); | ||
| String answer=scanner.next(); | ||
| if(answer.equalsIgnoreCase("y")){ | ||
| leetsGroup=generateRandomGroups(membersList,groupNum); | ||
| printResult(leetsGroup); | ||
| } | ||
| else if(answer.equalsIgnoreCase("n")){ | ||
| break; | ||
| } | ||
| } | ||
| }catch(IllegalArgumentException e){ | ||
| System.out.println("[ERROR]"+ e.getMessage()); | ||
| run(); | ||
| }finally{ | ||
| scanner.close(); | ||
| } | ||
| } |
There was a problem hiding this comment.
๋ฉ์๋๋ก ๋ฐ๋ก ๋ถ๋ฆฌํ๋๊ฒ ๋ ์ข์๋ณด์ ๋๋ค
| for(int i=0;i<afterMembers.size();i+=maximumGroupSize){ | ||
| groups.add(afterMembers.subList(i,Math.min(i+maximumGroupSize,afterMembers.size()))); | ||
| } |
There was a problem hiding this comment.
์ด๋ฐ ๋ฐฉ๋ฒ๋ ์๊ตฐ์ ๋ฐฐ์๊ฐ๋๋ค
| 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.
์ฌ๋1, ์ฌ๋2, (๋์ด์ฐ๊ธฐ 2๊ฐ) ์ฌ๋3,์ฌ๋4, ์ฌ๋5
์ด๋ ๊ฒ ๋์ด์ฐ๊ธฐ๊ฐ 0๊ฐ, 1๊ฐ, n๊ฐ์ธ ๊ฒฝ์ฐ์์ ์ด๋ฆ๋ง ์ถ๋ ฅ๋ ์ ์๋๋ก ํ๋ฉด ์ข์๊ฑฐ๊ฐ์์
jiixon
left a comment
There was a problem hiding this comment.
๋ค์๋ฒ์๋ ์ปค๋ฐ์ปจ๋ฒค์ ๋ ์ฌ์ฉํ์ฌ, ์ปค๋ฐ๋ฉ์์ง์๋ ์ ๊ฒฝ์ฐ๋ฉด ์ข์ ๊ฒ ๊ฐ์์! ๋๋ ์๋ฌ๋ถ๋ถ์ enum์ผ๋ก ๋ฐ๋ก Exceptionํ์ผ์์ ๊ด๋ฆฌํด๋ ์ข์๊ฒ ๊ฐ์์
| while(true){ | ||
| System.out.println("๋ง์์ ์๋ค์ด?(y/n)"); | ||
| String answer=scanner.next(); | ||
| if(answer.equalsIgnoreCase("y")){ | ||
| leetsGroup=generateRandomGroups(membersList,groupNum); | ||
| printResult(leetsGroup); | ||
| } | ||
| else if(answer.equalsIgnoreCase("n")){ | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
์๋ฌธ y์ n ์ด์ธ์ ๊ฐ์ด ๋ค์ด์์๋์ ์์ธ์ฒ๋ฆฌ๊ฐ ์๋๊ฒ ๊ฐ์๋ฐ, ์ข๋ ๊ตฌ์ฒด์ ์ธ ์๋ฌ ๋ก์ง์ ์ถ๊ฐํ๋๊ฒ ์ด๋จ๊น์?
| String leetsMember=scanner.nextLine(); | ||
| checkHasNoEnglish(leetsMember); | ||
|
|
||
| List<String> membersList=parseMembers((leetsMember)); |
There was a problem hiding this comment.
(())๊ดํธ ์ค๋ณต ์๋๊ฑฐ ๊ฐ์์!
| System.out.println("๋ง์์ ์๋ค์ด?(y/n)"); | ||
| String answer=scanner.next(); |
There was a problem hiding this comment.
print("")ํ nextLine()์ ์
๋ ฅ๋ฐ๋ ๊ฒ์ด ๊ฐ๋
์์ด ์ข ๋ ์ข์๋ณด์
๋๋ค!
| }catch(IllegalArgumentException e){ | ||
| System.out.println("[ERROR]"+ e.getMessage()); | ||
| run(); | ||
| }finally{ | ||
| scanner.close(); | ||
| } |
There was a problem hiding this comment.
e๋ก ๋๊ฒจ์ฃผ๋ ๊ฒ๋ณด๋ค๋ ๊ตฌ์ฒด์ ์ธ ์ผ์ด์ค์ ๋ฐ๋ผ์ ์๋ฌ๋ฉ์์ง๋ฅผ ๋ฃ๋๊ฒ์ด ์ข๋ ์ข์๊ฒ ๊ฐ์์
| if(members.matches(".*[a-zA-Z].*")){ | ||
| throw new IllegalArgumentException("์์ด๊ฐ ๋ค์ด๊ฐ๋ฉด ์๋๋ค."); | ||
| } |
There was a problem hiding this comment.
๋น ๊ฐ์ด ๋ค์ด๊ฐ ๊ฒฝ์ฐ๋ ์ถ๊ฐํ๋๊ฒ์ด ์ด๋จ๊น์?
| for(int i=0;i<result.size();i++){ | ||
| System.out.println(result.get(i)); | ||
| } |
There was a problem hiding this comment.
["์ด๋ฆ" | "์ด๋ฆ"] ํด๋น๊ณผ ๊ฐ์ ํํ๋ก ์ถ๋ ฅํด์ผํ๋๋ฐ, println์ผ๋ก ์ถ๋ ฅํ๋ฉด ๋ฆฌ์คํธ๋ก ์ถ๋ ฅ์ด ๋ ๊ฑฐ๊ฐ์๋ฐ, ์๊ตฌ์ฌํญ์ ๋ง๊ฒ printํจ์๋ฅผ ๋ค์ ๊ตฌ์ฑํ๋๊ฒ ์ด๋จ๊น์?
| List<String> afterMembers = new ArrayList<>(memberList); | ||
| Collections.shuffle(afterMembers); | ||
| List<List<String>> groups = new ArrayList<>(); |
There was a problem hiding this comment.
List๋ฅผ ์ฌ๋ฌ๋ฒ ์ ์ธํ๋๊ฒ๋ณด๋ค ๋ถํ์ํ ์ฝ๋๋ฅผ ์ค์ด๋๊ฒ ์ด๋จ๊น์? groups๋ง ์ฌ์ฉํ๋ฉด ์ข๋ ๊ฐ๊ฒฐํ ์ฝ๋๊ฐ ๋ ๊ฑฐ๊ฐ์์!
๋ฏธ์ ์คํ๊ฒฐ๊ณผ
๊ธฐ๋ฅ๋ช ์ธ์