From b4bd29642d3aaca6bfd181223b7379d57d665159 Mon Sep 17 00:00:00 2001 From: monsileI Date: Wed, 29 Jun 2022 21:12:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=ED=94=88=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20(=20=EB=A7=B5=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Basic_Of_Algorithm/src/test/openChatting.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Basic_Of_Algorithm/src/test/openChatting.java diff --git a/Basic_Of_Algorithm/src/test/openChatting.java b/Basic_Of_Algorithm/src/test/openChatting.java new file mode 100644 index 0000000..a68d28c --- /dev/null +++ b/Basic_Of_Algorithm/src/test/openChatting.java @@ -0,0 +1,52 @@ +package test; + +import java.util.HashMap; +import java.util.ArrayList; + +public class openChatting { + + public static void main(String[] args) { + + String[]record = {"Enter uid1234 Muzi", "Enter uid4567 Prodo","Leave uid1234","Enter uid1234 Prodo","Change uid4567 Ryan"}; + + HashMap map = new HashMap<>(); + + ArrayList answerList = new ArrayList<>(); + + for(String str : record) { + + String []temp = str.split(" "); + + String action = temp[0]; + String id = temp[1]; + if(action.equals("Leave"))continue; + String nick = temp[2]; + + map.put(id, nick); + + } + + + for(String str : record) { + + String []temp = str.split(" "); + + String action = temp[0]; + String id = temp[1]; + if(action.contains("Change"))continue; + String nick = map.get(id); + + String ans = nick+"님이 " + (action.equals("Enter") ? "들어왔습니다." : "나갔습니다."); + + answerList.add(ans); + } + + String[]answer = new String[answerList.size()]; + + for(int i=0;i