Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 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.Social_Media_Posts
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Dictionary<string, Dictionary<string, int>> social = new Dictionary<string, Dictionary<string, int>>();
  14. Dictionary<string, Dictionary<string, List<string>>> comments = new Dictionary<string, Dictionary<string, List<string>>>();
  15.  
  16. while (true)
  17. {
  18. var input = Console.ReadLine();
  19. if (input == "drop the media") break;
  20. var comm = input.Split(' ');
  21. var command = comm[0];
  22. var name = comm[1];
  23. if (command== "post")
  24. {
  25. if(!social.ContainsKey(name))
  26. social.Add(name, new Dictionary<string, int>());
  27. social[name].Add("Likes:", 0);
  28. social[name].Add("Dislikes:", 0);
  29. }
  30. else if (command == "like")
  31. {
  32. social[name]["Likes:"]++;
  33. }
  34. else if (command == "dislike")
  35. {
  36. social[name]["Dislikes:"]++;
  37. }
  38. else if (command == "comment")
  39. {
  40. var commentator = comm[2];
  41. if (!comments.ContainsKey(name))
  42. {
  43. comments.Add(name, new Dictionary<string, List<string>>());
  44. }
  45. comments[name].Add(commentator, new List<string>());
  46. for (int i = 3; i < comm.Length; i++)
  47. {
  48. comments[name][commentator].Add(comm[i]);
  49. }
  50. }
  51. }
  52. foreach (var item in social.Keys)
  53. {
  54. var likes = social[item];
  55. Console.Write("Post: {0} ",item);
  56. foreach (var like in likes)
  57. {
  58. Console.Write("| {0} {1} ", like.Key, like.Value);
  59. }
  60. Console.WriteLine();
  61. Console.WriteLine("Comments:");
  62. if (comments.ContainsKey(item))
  63. {
  64. var comentz = comments[item];
  65. foreach (var ppl in comentz)
  66. {
  67. Console.WriteLine("* {0}: {1}", ppl.Key, String.Join(" ", ppl.Value));
  68. }
  69. }
  70. else
  71. {
  72. Console.WriteLine("None");
  73. }
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement