package week02;
import java.util.*;
public class Sol2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String choiceDataStructure = sc.nextLine();
String cookingName = sc.nextLine();
int i = 1,j=0;
if(Objects.equals(choiceDataStructure,"List")){
LinkedList<String> recipeList = new LinkedList<String>();
while(true){
String rows = sc.nextLine();
if(Objects.equals(rows,"끝"))
break;
recipeList.add(rows);
}
System.out.println("[ "+choiceDataStructure+" 으로 저장된 "+cookingName + " ]");
while(!recipeList.isEmpty()){
System.out.println(i+". "+recipeList.poll());
i++;
}
}
else if (Objects.equals(choiceDataStructure,"Set")) {
LinkedHashSet<String> recipeSet = new LinkedHashSet<>();
while(true){
String rows = sc.nextLine();
if(Objects.equals(rows,"끝"))
break;
recipeSet.add(rows);
}
Iterator iterator = recipeSet.iterator();
System.out.println("[ "+choiceDataStructure+" 으로 저장된 "+cookingName + " ]");
while(j<recipeSet.size()){
System.out.println(i+". "+iterator.next());
i++;
j++;
}
}
else if (Objects.equals(choiceDataStructure,"Map")) {
Map<Integer,String> recipeMap = new HashMap<>();
while(true){
String rows = sc.nextLine();
if(Objects.equals(rows,"끝"))
break;
recipeMap.put(j,rows);
j++;
}
System.out.println("[ "+choiceDataStructure+" 으로 저장된 "+cookingName + " ]");
for (int k = 0; k < recipeMap.size(); k++) {
System.out.println((k+1)+". "+recipeMap.get(k));
}
}
}
}