ZhivkoPetkov

Classes- Mentor Group

Jun 18th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp3
  9. { class Mentor
  10.     {
  11.         public string Name { get; set; }
  12.        
  13.     }
  14.  
  15.     class Program
  16.     {
  17.         public static object Culture { get; private set; }
  18.  
  19.         static void Main(string[] args)
  20.         {
  21.             var dates = new Dictionary<string, List<DateTime>>();
  22.             var comments = new Dictionary<string, List<string>>();
  23.  
  24.             var input = Console.ReadLine();
  25.  
  26.             while (input != "end of dates")
  27.             {
  28.                 var info = input.Split(new char[] { ' ', ',' }).ToList();
  29.                 string name = info[0];
  30.  
  31.                 if (dates.ContainsKey(name)==false)
  32.                 {
  33.                     dates.Add(name, new List <DateTime>());
  34.                     comments.Add(name, new List <string>());
  35.                 }
  36.  
  37.                 for (int i = 1; i < info.Count; i++)
  38.                 {
  39.                     var currentDate = DateTime.ParseExact(info[i], "dd/MM/yyyy", CultureInfo.InvariantCulture);
  40.                     dates[name].Add(currentDate);
  41.                 }
  42.                 input = Console.ReadLine();
  43.             }
  44.  
  45.             var commentInfo = Console.ReadLine();
  46.  
  47.             while (commentInfo != "end of comments")
  48.             {
  49.                 var inputComment = commentInfo.Split('-').ToList();
  50.                 string name = inputComment[0];
  51.  
  52.                 if (comments.ContainsKey(name))
  53.                 {
  54.                     comments[name].Add(inputComment[1]);
  55.                 }
  56.  
  57.                 commentInfo = Console.ReadLine();
  58.             }
  59.  
  60.             foreach (var item in comments.OrderBy(x=>x.Key))
  61.             {
  62.                 Console.WriteLine($"{item.Key}\nComments:");
  63.                 foreach (var comment in item.Value)
  64.                 {
  65.                     Console.WriteLine($"- {comment}");
  66.                 }
  67.                 Console.WriteLine($"Dates attended:");
  68.                 foreach (var date in dates[item.Key].OrderBy(x=>x.Date))
  69.                 {
  70.                     Console.WriteLine($"-- {date:dd/MM/yyyy}");
  71.                 }
  72.             }
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment