Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _4.Group_Continents__Countries_and_Cities
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. {
  14.  
  15. Dictionary <string, Dictionary<string, List<string>>> commentsDB = new Dictionary<string, Dictionary<string, List<string>>>();
  16. Dictionary<string, int> likesDB = new Dictionary<string, int>();
  17. Dictionary<string, int> dislikesDB = new Dictionary<string, int>();
  18.  
  19. string input = Console.ReadLine();
  20.  
  21. while (input != "drop the media")
  22. {
  23. string[] tokens = input.Split(' ');
  24.  
  25. string command = tokens[0];
  26.  
  27. if (!likesDB.ContainsKey(tokens[1]))
  28. {
  29. likesDB[tokens[1]] = 0;
  30. }
  31.  
  32. if (!dislikesDB.ContainsKey(tokens[1]))
  33. {
  34. dislikesDB[tokens[1]] = 0;
  35. }
  36.  
  37. switch (command)
  38. {
  39. case "post":
  40. commentsDB[tokens[1]] = new Dictionary<string, List<string>>();
  41. break;
  42.  
  43. case "like":
  44. likesDB[tokens[1]] += 1;
  45. break;
  46.  
  47. case "dislike":
  48. dislikesDB[tokens[1]] += 1;
  49. break;
  50.  
  51. case "comment":
  52. commentsDB[tokens[1]].Add(tokens[2], new List<string>());
  53. for (int i = 3; i < tokens.Length; i++)
  54. {
  55. commentsDB[tokens[1]][tokens[2]].Add(tokens[i]);
  56. }
  57.  
  58. break;
  59. }
  60.  
  61. input = Console.ReadLine();
  62. }
  63.  
  64. foreach (var post in commentsDB)
  65. {
  66. Console.WriteLine($"Post: {post.Key} | Likes: {likesDB[post.Key]} | Dislikes: {dislikesDB[post.Key]}");
  67. Console.WriteLine("Comments:");
  68. var comments = post.Value;
  69. if (post.Value.Count == 0)
  70. {
  71. Console.WriteLine("None");
  72. }
  73. else
  74. {
  75. foreach (var item in comments)
  76. {
  77. Console.WriteLine("* {0}: {1}", item.Key, String.Join(" ", item.Value));
  78. }
  79.  
  80. }
  81.  
  82. }
  83. }
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement