Advertisement
Guest User

Mentor Group

a guest
Oct 13th, 2016
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic; //ne raboti !!!
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. public class MentorGroup
  9. {
  10. public static void Main()
  11. {
  12. string input = Console.ReadLine();
  13. SortedDictionary<string, Student> students = new SortedDictionary<string, Student>();
  14.  
  15. while (input != "end of dates")
  16. {
  17. string[] studentInfo = input.Split(' ');
  18. string name = studentInfo[0];
  19. string[] dateSeq = studentInfo[1].Split(',');
  20. List<DateTime> dates = new List<DateTime>();
  21.  
  22. for (int i = 0; i < dateSeq.Length; i++)
  23. {
  24. DateTime currDate = DateTime.ParseExact(dateSeq[i], "dd/MM/yyyy", CultureInfo.InvariantCulture);
  25. dates.Add(currDate);
  26. }
  27.  
  28. Student student = new Student();
  29. student.Name = name;
  30.  
  31. if (!students.ContainsKey(name))
  32. {
  33. students.Add(name, student);
  34. student.Attendency = dates;
  35. }
  36. else
  37. {
  38. students[name].Attendency.AddRange(dates);
  39. }
  40.  
  41. input = Console.ReadLine();
  42. }
  43.  
  44. string secondInput = Console.ReadLine();
  45.  
  46. while (secondInput != "end of comments")
  47. {
  48. string[] commentsInfo = secondInput.Split('-');
  49. string name = commentsInfo[0];
  50. string comment = commentsInfo[1];
  51. List<string> comments = new List<string>();
  52. comments.Add(comment);
  53.  
  54. if (students.ContainsKey(name))
  55. {
  56. if (students[name].Comments != null)
  57. {
  58. students[name].Comments.AddRange(comments);
  59. }
  60. else
  61. {
  62. students[name].Comments = comments;
  63. }
  64. }
  65.  
  66. secondInput = Console.ReadLine();
  67. }
  68.  
  69. foreach (var entry in students)
  70. {
  71. Console.WriteLine("{0}", entry.Key);
  72. Console.WriteLine("Comments:");
  73.  
  74. if (entry.Value.Comments != null)
  75. {
  76. foreach (var comment in entry.Value.Comments)
  77. {
  78. Console.WriteLine("- {0}", comment);
  79. }
  80. }
  81.  
  82. Console.WriteLine("Dates attended:");
  83.  
  84. foreach (var date in entry.Value.Attendency.OrderBy(d => d))
  85. {
  86. Console.WriteLine("-- {0:dd/MM/yyyy}", date);
  87. }
  88. }
  89. }
  90. }
  91.  
  92. public class Student
  93. {
  94. public string Name { get; set; }
  95. public List<DateTime> Attendency { get; set; }
  96. public List<string> Comments { get; set; }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement