Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Basic_Of_Algorithm/src/test/openChatting.java
Original file line number Diff line number Diff line change
@@ -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<String,String> map = new HashMap<>();

ArrayList<String> 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<answer.length;i++)answer[i] = answerList.get(i);

for(String str : answer) System.out.println(str);

}

}