Advertisement
Guest User

Untitled

a guest
Apr 5th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. package retakeEXAMS;
  2.  
  3. import java.util.LinkedHashMap;
  4. import java.util.Scanner;
  5.  
  6. public class MeTubeStatistics {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. LinkedHashMap<String, Integer> views = new LinkedHashMap<>();
  11. LinkedHashMap<String, Integer> likes = new LinkedHashMap<>();
  12.  
  13. String input = "";
  14. while (!"stats time".equals(input = scanner.nextLine())) {
  15.  
  16.  
  17. String[] array = input.split("-|:");
  18. if (input.contains("-")){
  19.  
  20.  
  21. String name = array[0];
  22. int like = Integer.parseInt(array[1]);
  23.  
  24. if (!views.containsKey(name)) {
  25. views.put(name, like);
  26. } else {
  27. views.put(name, views.get(name) + like);
  28. }
  29.  
  30. }else if (input.contains(":")) {
  31.  
  32. String command = array[0];
  33. String name = array[1];
  34.  
  35.  
  36. switch (command) {
  37.  
  38. case "like":
  39.  
  40. if (!likes.containsKey(name)) {
  41. likes.put(name, 1);
  42. } else {
  43. likes.put(name, likes.get(name) + 1);
  44. }
  45. break;
  46. case "dislike":
  47.  
  48. if (likes.containsKey(name)) {
  49. likes.put(name, likes.get(name) - 1);
  50. }
  51. break;
  52. }
  53. }
  54.  
  55. }
  56.  
  57.  
  58. String input2 = scanner.nextLine();
  59.  
  60. if (input2.equals("by likes")) {
  61.  
  62.  
  63. }else if (input2.equals("by views")){
  64.  
  65.  
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement