Advertisement
vdjalov

Untitled

Oct 4th, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. package customList;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. public class Main {
  8.  
  9. public static void main(String[] args) throws IOException {
  10.  
  11. BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  12. @SuppressWarnings({ "rawtypes", "unchecked" })
  13. CustomList<String> list = new CustomList(String.class);
  14.  
  15. while(true){
  16. String input [] = bf.readLine().split("[ ]+");
  17. if(input[0].equalsIgnoreCase("end")){
  18. break;
  19. }
  20.  
  21. switch(input[0]){
  22.  
  23. case "Add":
  24. list.add(input[1]);
  25. break;
  26. case "Remove":
  27. list.remove(Integer.valueOf(Integer.valueOf(input[1])));
  28. break;
  29. case "Contains":
  30. System.out.println(list.contains(input[1]));
  31. break;
  32. case "Swap":
  33. list.swap(Integer.valueOf(input[1]), Integer.valueOf(input[2]));
  34. break;
  35. case "Greater":
  36. System.out.println(list.countGreaterThan(input[1]));
  37. break;
  38. case "Max":
  39. System.out.println(list.getMax());
  40. break;
  41. case "Min":
  42. System.out.println(list.getMin());
  43. break;
  44. case "Print":
  45. list.print();
  46. break;
  47. case "Sort":
  48. Sorter.sort(list);
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement