Advertisement
akkirilov

Untitled

Feb 8th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Globalization;
  5.  
  6. namespace _08_Mentor_Group
  7. {
  8. public class Student
  9. {
  10. public string Name { get; set; }
  11. public List<string> Comments { get; set; }
  12. public List<DateTime> Attendency { get; set; }
  13. }
  14.  
  15. public class MentorGroup
  16. {
  17. static void Main()
  18. {
  19. SortedDictionary<string, Student> students = new SortedDictionary<string, Student>();
  20.  
  21. string input = Console.ReadLine();
  22. while (input != "end of dates")
  23. {
  24. string[] inputEll = input.Split().ToArray();
  25.  
  26. if (inputEll.Length > 1)
  27. {
  28. List<DateTime> currentAttend = inputEll[1].Split(',')
  29. .Select(x => DateTime.ParseExact(x, "dd\\/MM\\/yyyy", CultureInfo.InvariantCulture))
  30. .ToList();
  31.  
  32. if (students.ContainsKey(inputEll[0]))
  33. {
  34. students[inputEll[0]].Attendency.AddRange(currentAttend);
  35. }
  36. else
  37. {
  38. Student currentStudent = new Student
  39. {
  40. Name = inputEll[0],
  41. Attendency = currentAttend,
  42. Comments = new List<string>()
  43. };
  44.  
  45. students[inputEll[0]] = currentStudent;
  46. }
  47. }
  48.  
  49. input = Console.ReadLine();
  50. }
  51.  
  52. input = Console.ReadLine();
  53. while (input != "end of comments")
  54. {
  55. string[] inputEll = input.Split('-').ToArray();
  56.  
  57. if (students.ContainsKey(inputEll[0]))
  58. {
  59. students[inputEll[0]].Comments.Add(inputEll[1]);
  60. }
  61.  
  62. input = Console.ReadLine();
  63. }
  64.  
  65. foreach (var student in students)
  66. {
  67. if (student.Value.Attendency.Count > 0)
  68. {
  69. Console.WriteLine(student.Value.Name);
  70.  
  71. Console.WriteLine("Comments:");
  72. foreach (var comment in student.Value.Comments)
  73. {
  74. Console.WriteLine($"- {comment}");
  75. }
  76.  
  77. Console.WriteLine("Dates attended:");
  78. foreach (var attend in student.Value.Attendency.OrderBy(x => x))
  79. {
  80. Console.WriteLine($"-- {attend.ToString("dd\\/MM\\/yyyy")}");
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement