package com.company;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Solution {
static public void main(String[] args) {
String[] quiz = new String[]{"Enter uid1234 Muzi", "Enter uid4567 Prodo", "Leave uid1234", "Enter uid1234 Prodo", "Change uid4567 Ryan"};
String[] quizAnswer = new String[]{"Prodo님이 들어왔습니다.", "Ryan님이 들어왔습니다.", "Prodo님이 나갔습니다.", "Prodo님이 들어왔습니다."};
System.out.println(Arrays.equals(solution(quiz),quizAnswer));
}
static public String[] solution(String[] record) {
String[] answer = {};
String[][] splitRecodeArray = new String[record.length][];
HashMap<String, String> hashMap = new HashMap<>();
String command = null;
List<String> answerList = new ArrayList<>();
int index = 0;
for (String string : record) {
splitRecodeArray[index] = string.split(" ");
index++;
}
for (int i = 0; i < record.length; i++) {
command = splitRecodeArray[i][0];
if(!command.equals("Leave"))
hashMap.put(splitRecodeArray[i][1], splitRecodeArray[i][2]);
}
for (int i = 0; i < record.length; i++) {
command = splitRecodeArray[i][0];
String tailString = "";
if(command.equals("Enter")){
tailString = "님이 들어왔습니다.";
}
else if(command.equals("Leave")){
tailString = "님이 나갔습니다.";
}
else{
continue;
}
answerList.add(hashMap.get(splitRecodeArray[i][1]) + tailString);
}
return answerList.toArray(answer);
}
}