[BE] ์ด๊ทผํ ๐ฅ ์ค๋์ ์ง๊ฟ์?#15
Conversation
taeseokyang
left a comment
There was a problem hiding this comment.
์๊ณ ํ์ จ์ต๋๋ค!!!!
| public void run() { | ||
| System.out.println("๋ฉค๋ฒ์ ์ด๋ฆ์ ์ ๋ ฅํด ์ฃผ์ธ์. (, ๋ก ๊ตฌ๋ถ)"); | ||
| Scanner sc = new Scanner(System.in); | ||
| String input = sc.nextLine(); |
There was a problem hiding this comment.
๋ฌด์จ ์ ๋ ฅ์ธ์ง ๋ํ๋ด๋ ๋ณ์๋ช ์ด๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค!
| System.out.println("์ต๋ ์ง ์๋ฅผ ์ ๋ ฅํด ์ฃผ์ธ์."); | ||
| int maxNum = Integer.parseInt(sc.nextLine()); | ||
| checkDataValidity(memberList.size(), maxNum); | ||
| String flag ="true"; |
There was a problem hiding this comment.
๋ฌด์จ ํ๋๊ทธ ์ธ์ง ์๋ ค์ฃผ๋ฉด ์ข์๊ฑฐ ๊ฐ์ต๋๋ค!
๋ณ์๋ช
๋ง ๋ณด๊ณ ๋ฐ๋ก ์ดํด ํ๋ฉด ์ฝ๋๋ฅผ ์ฝ๊ธฐ ๋์ฑ ํธํ ๊ฑฐ ๊ฐ์ต๋๋ค!
boolean ํ ๋ณ๊ฒฝํ๋ ๊ฒ๋ ์ข๋ค ์๊ฐํฉ๋๋ค! ๋ง์ฝ ๊ทธ๋ ๋ค๋ฉด isDone์ ์ด๋จ๊น์?
ํ์ฌ String ํ์ผ๋ก true, exception์ ๋ฐํ ๋ฐ๊ณ ์๋๋ฐ, isContinue() ํจ์์์๋ ๊ณ์ ํ ์ง ์ํ ์ง true, false ๋์ค ํ๋๋ง ๋ฐํํ๋ฉด ๋๋ค ์๊ฐํฉ๋๋ค!
| // ๋ฌธ์์ด๋ก๋ ๋ฉค๋ฒ๋ค์ ๋ฆฌ์คํธ๋ก ๋ถ๋ฆฌํ๋ ํจ์์ ๋๋ค. | ||
| public List<String> parseMembers(String members) { | ||
| return new ArrayList<>(); | ||
| List<String> memberList = new ArrayList<>(); |
There was a problem hiding this comment.
return Arrays.asList(members.split(","));
์์ ๊ฐ์ด ์์ฑ ํ ์ ์์ต๋๋ค!
| int maxNum = Integer.parseInt(sc.nextLine()); | ||
| checkDataValidity(memberList.size(), maxNum); | ||
| String flag ="true"; | ||
| while (flag.equals("true") || flag.equals("exception")) { |
There was a problem hiding this comment.
๋ง์ฝ flag ๊ฐ null ์ด๋ผ๋ฉด ์ด๋ค ๋ฌธ์ ๊ฐ ์์๊น์?
๊ทธ๋ฆฌ๊ณ ์ด๋ฅผ ๋ฐฉ์งํ๊ธฐ ์ํด ์ด๋ป๊ฒ ํด์ผํ ๊น์?
| public void checkHasNoEnglish(String members) { | ||
| try { | ||
| for (char c : members.toCharArray()) { | ||
| if (!(c >= '๊ฐ' && c <= 'ํฃ') && !(Character.toString(c).equals(","))) { |
There was a problem hiding this comment.
๋ณต์กํ ์กฐ๊ฑด๋ฌธ์ ๋ฉ์๋๋ก ๋ฐ๋ก ๋นผ๋ฉด ๊ฐ๋ ์ฑ์ด ์ฃ ์์ ธ์ ๐
| } | ||
| } catch (Exception e) { | ||
| System.out.println(e.getMessage()); | ||
| run(); |
There was a problem hiding this comment.
์ซ์ ์ค์ํ๋ฉด ์ด๋ฆ๊น์ง ๋ค์ ์ ๋ ฅ๋ฐ๋ ํ๋์ฝ์ด ํ๋ก๊ทธ๋จ์ด ๋์๋ค์! ๐
| for (List<String> line : result) { | ||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append("[ "); | ||
| for (String s : line) { | ||
| sb.append(s).append(" | "); | ||
| } | ||
| sb.replace(sb.length()-2,sb.length(),"]"); | ||
| System.out.println(sb); | ||
| } |
There was a problem hiding this comment.
StringJoiner์ ๋ํด ์์๋ณด๋ฉด ํธํด์ง๊ฑฐ์์!
| if (q.equals("n")) { | ||
| System.out.println("์๋ฆฌ๋ฅผ ์ด๋ํด ์๋ก์๊ฒ ์ธ์ฌํด์ฃผ์ธ์."); | ||
| return "false"; | ||
| } else if (q.equals("y")) { | ||
| System.out.println("--------------------------------"); | ||
| return "true"; | ||
| } else { | ||
| System.out.println("[ERROR] y ํน์ n๋ง ์ ๋ ฅํด์ฃผ์ธ์."); | ||
| return "exception"; | ||
| } |
There was a problem hiding this comment.
else ๋ ์์ด๋ ๋๊ฒ ๋ค์!
| public static String isContinue() { | ||
| System.out.print("๋ค์ ๊ตฌ์ฑํ์๊ฒ ์ต๋๊น? (y or n): "); | ||
| Scanner sc = new Scanner(System.in); | ||
| String q = sc.nextLine(); |
There was a problem hiding this comment.
q ๋ ๋ฌด์์ ์๋ฏธํ๋์?
-๋ค์ ๋ฝ๊ธฐ๋ฅผ ์ํ while ๋ฌธ์ flag ๋ณ์ ํ์ ์ Boolean์ผ๋ก ๋ณ๊ฒฝ -flag ๋ณ์์ ์ด๋ฆ์ isDone์ผ๋ก ์์ -isContinue์ ๋ฐํ๊ฐ์ Boolean์ผ๋ก ์์
-for๋ฌธ ๋์ asList๋ฅผ ์ด์ฉํ์ฌ ๋ฉค๋ฒ๋ฅผ ๋ถ๋ฆฌํ๋๋ก ๋ณ๊ฒฝ
| Boolean isDone = true; | ||
| while (isDone .equals(true)) { | ||
| printResult(generateRandomGroups(memberList,maxNum)); | ||
| isDone = isContinue(); |
There was a problem hiding this comment.
while (isDone) { ์ด๋ ๊ฒ ๊ตฌํํด๋ ๋์ง์์๊น์?
ํ ์คํธ ๊ฒฐ๊ณผ
์คํ๊ฒฐ๊ณผ
๊ธฐ๋ฅ ๋ช ์ธ์
โ ์ ๋ ฅ๋ฐ์ ์ด๋ฆ์ , ๊ธฐ์ค์ผ๋ก ์ด๋ฆ ๋ฆฌ์คํธ ์์ฑ
โ ์ ๋ ฅ๋ ์ด๋ฆ ์๋ฅผ ์ ์ฅํ๋ ๋ฉ์๋ ๊ตฌํ
โ ์ง์๋ฅผ ์ ๋ ฅ ๋ฐ๊ณ ๋ฆฌ์คํธ์ ํฌ๊ธฐ ๋ณด๋ค ํฌ๋ฉด ์์ธ๋ฅผ ์ฒ๋ฆฌ
โ ๋ค์ ๋ฝ๊ธฐ ์คํ์ y,n ์ ์ ์ธํ ๋ฌธ์๊ฐ ์ ๋ ฅ ๋ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌ
โ ์ง์ ๋ฝ๊ณ ์ฃผ์ด์ง ํ์์ ๋ง๊ฒ ์ถ๋ ฅํ๋ ๋ฉ์๋ ๊ตฌํ