Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Social_Media_Posts
- {
- public class SocialMediaPosts
- {
- public static void Main()
- {
- Dictionary<string, Dictionary<string, string>> commentsDB = new Dictionary<string, Dictionary<string, string>>();
- Dictionary<string, int> likesDB = new Dictionary<string, int>();
- Dictionary<string, int> dislikesDB = new Dictionary<string, int>();
- string input = Console.ReadLine();
- while (input != "drop the media")
- {
- string[] tokens = input.Split(' ');
- string command = tokens[0];
- if (!likesDB.ContainsKey(tokens[1]))
- {
- likesDB[tokens[1]] = 0;
- }
- if (!dislikesDB.ContainsKey(tokens[1]))
- {
- dislikesDB[tokens[1]] = 0;
- }
- switch (command)
- {
- case "post":
- commentsDB[tokens[1]] = new Dictionary<string, string>();
- break;
- case "like":
- likesDB[tokens[1]] += 1;
- break;
- case "dislike":
- dislikesDB[tokens[1]] += 1;
- break;
- case "comment":
- commentsDB[tokens[1]][tokens[2]] = tokens[3];
- break;
- }
- input = Console.ReadLine();
- }
- foreach (var post in commentsDB)
- {
- Console.WriteLine($"Post: {post.Key} | Likes: {likesDB[post.Key]} | Dislikes: {dislikesDB[post.Key]}");
- Console.WriteLine("Comments:");
- foreach (var key in post.Value.Keys)
- {
- Console.WriteLine("* " + key + ": ");
- //How to print the comment? Please help
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement