veronikaaa86

Mnogo Sum Zle

Feb 9th, 2018
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package MapLambdaStream;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.LinkedHashMap;
  7.  
  8. public class P02_PhonebookUpgrade {
  9.     public static void main(String[] args) throws IOException {
  10.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  11.  
  12.         LinkedHashMap<String, String> phonebookMap = new LinkedHashMap<>();
  13.  
  14.         String command = "";
  15.         while (!"END".equals(command = reader.readLine())) {
  16.             String[] input = command.split("\\s+");
  17.  
  18.             if ("A".equals(input[0])) {
  19.                 phonebookMap.put(input[1], input[2]);
  20.             } else if ("S".equals(input[0])){
  21.                 if (phonebookMap.containsKey(input[1])) {
  22.                     System.out.printf("%s -> %s%n", input[1], phonebookMap.get(input[1]));
  23.                 } else {
  24.                     System.out.printf("Contact %s does not exist.%n", input[1]);
  25.                 }
  26.             } else if ("ListAll".equals(command)) {
  27.                 //print all contacts ordered lexicographically
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment