Advertisement
Guest User

MentorGroup.08

a guest
Oct 16th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 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.Skip(1).ToArray();
  20. List<DateTime> dates = new List<DateTime>();
  21. if (dateSeq.Length != 0)
  22. {
  23. for (int i = 0; i < dateSeq.Length; i++)
  24. {
  25. DateTime currDate = DateTime.ParseExact(dateSeq[i], "dd/MM/yyyy", CultureInfo.InvariantCulture);
  26. dates.Add(currDate);
  27. }
  28.  
  29. Student student = new Student();
  30. student.Name = name;
  31.  
  32. if (!students.ContainsKey(name) && dates.Count != 0)
  33. {
  34. students.Add(name, student);
  35. student.Attendency = dates;
  36. }
  37. else
  38. {
  39. students[name].Attendency.AddRange(dates);
  40. }
  41. }
  42. input = Console.ReadLine();
  43. }
  44.  
  45. string secondInput = Console.ReadLine();
  46.  
  47. while (secondInput != "end of comments")
  48. {
  49. string[] commentsInfo = secondInput.Split('-');
  50. string name = commentsInfo[0];
  51. string comment = commentsInfo[1];
  52. List<string> comments = new List<string>();
  53. comments.Add(comment);
  54.  
  55. if (students.ContainsKey(name))
  56. {
  57. if (students[name].Comments != null)
  58. {
  59. students[name].Comments.AddRange(comments);
  60. }
  61. else
  62. {
  63. students[name].Comments = comments;
  64. }
  65. }
  66.  
  67. secondInput = Console.ReadLine();
  68. }
  69.  
  70. foreach (var entry in students)
  71. {
  72. Console.WriteLine("{0}", entry.Key);
  73. Console.WriteLine("Comments:");
  74.  
  75. if (entry.Value.Comments != null)
  76. {
  77. foreach (var comment in entry.Value.Comments)
  78. {
  79. Console.WriteLine("- {0}", comment);
  80. }
  81. }
  82.  
  83. Console.WriteLine("Dates attended:");
  84. if (entry.Value.Attendency != null)
  85. {
  86. foreach (var date in entry.Value.Attendency.OrderBy(d => d))
  87. {
  88. Console.WriteLine("-- {0:dd/MM/yyyy}", date);
  89. }
  90. }
  91. }
  92. }
  93. }
  94.  
  95. public class Student
  96. {
  97. public string Name { get; set; }
  98. public List<DateTime> Attendency { get; set; }
  99. public List<string> Comments { get; set; }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement