diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e326adb --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3649e93 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a32791e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/onboarding.iml b/.idea/onboarding.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/onboarding.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git "a/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Daewoole.java" "b/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Daewoole.java" index 40d4298..5a66cbc 100644 --- "a/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Daewoole.java" +++ "b/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Daewoole.java" @@ -1,5 +1,24 @@ package com.example.maddaewoole; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class Daewoole { + public int now_anger = 0; + public int anger_threshold; + public Map anger_map = new HashMap<>(); -} + public int getAnger_threshold() { + return anger_threshold; + } + Daewoole(List str){ + anger_threshold = (int) ((Math.random() * 40) + 80); + anger_map.put(str.get(0), (int)(Math.random() * 10000) % 20); + anger_map.put(str.get(1), (int)(Math.random() * 20) + 10); + anger_map.put(str.get(2), (int)(Math.random() * 20) + 30); + } + int beProvinced(String str){ + return anger_map.get(str); + } +} \ No newline at end of file diff --git "a/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Jpark2.java" "b/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Jpark2.java" index a786814..2e30eac 100644 --- "a/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Jpark2.java" +++ "b/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Jpark2.java" @@ -1,5 +1,17 @@ package com.example.maddaewoole; + +import java.util.List; + public class Jpark2 { + private List str = List.of("'당신의 지각비, 회식비로 대체되었다'", "'코딩 그렇게 하는 거 아닌데'", "'오늘 저녁은 감탄계'"); + + String prov(){ + int random_num = (int) ((Math.random()*10000)%3); + return str.get(random_num); + } + public List getStr() { + return str; + } } diff --git "a/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Main.java" "b/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Main.java" index b8d6ddd..df2a835 100644 --- "a/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Main.java" +++ "b/v1/backend/JAVA_LV_0_\354\236\274\353\257\274_\355\216\200\354\271\230/src/main/java/com/example/maddaewoole/Main.java" @@ -3,6 +3,21 @@ public class Main { public static void main(String[] args) { + Jpark2 jiwon = new Jpark2(); + Daewoole daewook = new Daewoole(jiwon.getStr()); + int attack_cnt = 0; + while (true) { + String attack = jiwon.prov(); + int daewookAnger = daewook.beProvinced(attack); + System.out.println("지원은 " + attack + "를 시전하여 대욱의 분노를 " + daewookAnger + " 증가시켰다."); + daewook.now_anger += daewookAnger; + System.out.println("현재 대욱의 분노 수치 : " + daewook.now_anger); + if (daewook.now_anger > daewook.getAnger_threshold()) { + break; + } + attack_cnt++; + } + System.out.println("대욱을 도발한 횟수 : " + attack_cnt + "회"); } } diff --git "a/v1/backend/JAVA_LV_1_\354\225\214\353\260\224\354\235\230_\353\213\254\354\235\270/src/main/java/com/example/bot/BotImpl.java" "b/v1/backend/JAVA_LV_1_\354\225\214\353\260\224\354\235\230_\353\213\254\354\235\270/src/main/java/com/example/bot/BotImpl.java" index 029ec1b..abe0282 100644 --- "a/v1/backend/JAVA_LV_1_\354\225\214\353\260\224\354\235\230_\353\213\254\354\235\270/src/main/java/com/example/bot/BotImpl.java" +++ "b/v1/backend/JAVA_LV_1_\354\225\214\353\260\224\354\235\230_\353\213\254\354\235\270/src/main/java/com/example/bot/BotImpl.java" @@ -1,14 +1,88 @@ package com.example.bot; +import java.util.HashMap; +import java.util.Map; + + public class BotImpl implements JiwonBehavior { + private final Map product = new HashMap<>(); + @Override public void takeOrder(String order) { + if (order.equals("얼마야?")) { + result(); + return; + } + int loc = order.indexOf('>'); + String name = order.substring(1, loc); + order = order.substring(loc + 1); + + if (order.equals("빼")) { + outProduct(name); + } else if (order.equals("시켰나?")) { + didIOrdered(name); + } else if (order.equals("몇 개야?")) { + howManyOrdered(name); + } else { + orderProducts(order, name); + } + } + + private void orderProducts(String order, String name) { + int price = name.length() * 1000; + if (product.containsKey(name)) { + product.put(name, product.get(name) + 1); + } else { + product.put(name, 1); + } + + if (order.indexOf('랑') >= 0) { + int loc = order.indexOf('<'); + name = order.substring(loc + 1, order.length() - 1); + price += name.length() * 1000; + if (product.containsKey(name)) { + product.put(name, product.get(name) + 1); + } else { + product.put(name, 1); + } + + } + System.out.println("네 " + price + "원이요"); + } + + private void outProduct(String name) { + if (product.containsKey(name)) { + product.remove(name); + System.out.println("네"); + } else { + System.out.println("<" + name + ">안 시키셨어요"); + } + } + + private void didIOrdered(String name) { + if (product.containsKey(name)) { + System.out.println("<" + name + ">시키셨어요"); + } else { + System.out.println("<" + name + ">안 시키셨어요"); + } + } + private void howManyOrdered(String name) { + if (product.containsKey(name)) { + System.out.println("<" + name + ">" + product.get(name) + "개요"); + } else { + System.out.println("<" + name + ">안 시키셨어요"); + } } @Override public void result() { + int total = 0; + for (String key : product.keySet()) { + total += key.length() * 1000 * product.get(key); + } + System.out.println("총 " + total + "원 입니다"); } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BFS.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BFS.java" index 6a84351..dae45ed 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BFS.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BFS.java" @@ -2,4 +2,15 @@ public class BFS implements Algorithm { + boolean isSolved = false; + + @Override + public boolean isSolution(Algorithm algorithm) { + return algorithm instanceof BFS; + } + + @Override + public String getSolution() { + return "주변부터 둘러보기"; + } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BinarySearch.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BinarySearch.java" index 1981fb0..980141e 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BinarySearch.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/BinarySearch.java" @@ -2,4 +2,12 @@ public class BinarySearch implements Algorithm { + public boolean isSolution(Algorithm algorithm) { + return algorithm instanceof BinarySearch; + } + + @Override + public String getSolution() { + return "반띵 ㄱㄱ"; + } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DFS.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DFS.java" index 3685181..067f87a 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DFS.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DFS.java" @@ -2,4 +2,12 @@ public class DFS implements Algorithm { + public boolean isSolution(Algorithm algorithm) { + return algorithm instanceof DFS; + } + + @Override + public String getSolution() { + return "너에게 닿기를..."; + } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DP.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DP.java" index 083e387..96d8e4b 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DP.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/DP.java" @@ -2,4 +2,12 @@ public class DP implements Algorithm { + public boolean isSolution(Algorithm algorithm) { + return algorithm instanceof DP; + } + + @Override + public String getSolution() { + return "누가 첫날부터 DP문제를 들고옵니까"; + } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Main.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Main.java" index e203928..2f771d2 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Main.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Main.java" @@ -1,8 +1,38 @@ package com.example.algorithmbot; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class Main { public static void main(String[] args) { + BFS bfs = new BFS(); + DFS dfs = new DFS(); + TwoPointer twoPointer = new TwoPointer(); + BinarySearch binarySearch = new BinarySearch(); + DP dp = new DP(); + + List algorithm = new ArrayList<>( + Arrays.asList(bfs, dfs, twoPointer, binarySearch, dp)); + List todayAlgorithm = new ArrayList<>( + Arrays.asList("BFS", "DFS", "TwoPointer", "BinaraySearch", "DP")); + + Wchae wchae = new Wchae(); + + for (int i = 0; i < 20; i++) { + int today1 = (int) ((Math.random() * 10) % 5); + int today2 = (int) ((Math.random() * 10) % 5); + + Algorithm todayAlgorithm1 = algorithm.get(today1); + Algorithm todayAlgorithm2 = algorithm.get(today2); + + System.out.println( + "오늘의 알고리즘 : " + todayAlgorithm.get(today1) + ", " + todayAlgorithm.get(today2)); + System.out.println( + "우주 : " + wchae.solveAlgorithm(todayAlgorithm1) + " / " + wchae.solveAlgorithm( + todayAlgorithm2)); + } } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/TwoPointer.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/TwoPointer.java" index 15f5ba3..0bad381 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/TwoPointer.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/TwoPointer.java" @@ -2,4 +2,12 @@ public class TwoPointer implements Algorithm { + public boolean isSolution(Algorithm algorithm) { + return algorithm instanceof TwoPointer; + } + + @Override + public String getSolution() { + return "너에게 닿기를..."; + } } diff --git "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Wchae.java" "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Wchae.java" index 8e3087a..e2406fa 100644 --- "a/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Wchae.java" +++ "b/v1/backend/JAVA_LV_2_\354\225\214\352\263\240\353\246\254\354\246\230\354\235\230_\352\265\264\353\240\210/src/main/java/com/example/algorithmbot/Wchae.java" @@ -1,5 +1,30 @@ package com.example.algorithmbot; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + public class Wchae { + private final Map algorithmMap = new HashMap<>(); + + public String solveAlgorithm(Algorithm haveToSolve) { + Optional today1 = algorithmMap.keySet().stream() + .filter(x -> x.isSolution(haveToSolve)).findFirst(); + + if (today1.isPresent()) { + int solved_cnt = algorithmMap.getOrDefault(haveToSolve, 0); + algorithmMap.put(haveToSolve, solved_cnt + 1); + double percentage = Math.random(); + if ((double) solved_cnt * 0.1 > percentage) { + return haveToSolve.getSolution(); + } else { + return "스트레스 받네..."; + } + } else { + algorithmMap.put(haveToSolve, 1); + return "스트레스 받네..."; + } + } + }