Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Globalization;
  7. namespace Mentor_Group
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14.  
  15. List<Person> groupsList = new List<Person>();
  16.  
  17.  
  18. while (input!= "end of dates")
  19. {
  20. Person currentPerson = new Person();
  21. List<DateTime> myDateTimes = new List<DateTime>();
  22.  
  23. string[] commands = input.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  24.  
  25. string name = commands[0];
  26.  
  27.  
  28. for (int i = 1; i < commands.Length; i++)
  29. {
  30. DateTime date = DateTime.ParseExact(commands[i], "dd/MM/yyyy", CultureInfo.InvariantCulture);
  31. myDateTimes.Add(date);
  32. }
  33.  
  34. bool doesExist = false;
  35.  
  36. foreach (var person in groupsList.Where(x=> x.Name.Equals(name)))
  37. {
  38. person.AttendeDateTimes.AddRange(myDateTimes);
  39. doesExist = true;
  40. }
  41. if (!doesExist)
  42. {
  43. currentPerson.Name = name;
  44. currentPerson.AttendeDateTimes = myDateTimes;
  45. currentPerson.CommentList=new List<string>();
  46. groupsList.Add(currentPerson);
  47. }
  48.  
  49. input = Console.ReadLine();
  50. }
  51.  
  52. string input2 = Console.ReadLine();
  53.  
  54. while (input2!= "end of comments")
  55. {
  56. string[] commands = input2.Split('-').ToArray();
  57.  
  58. string name = commands[0];
  59. string comments = commands[1];
  60.  
  61. foreach (var person in groupsList.Where(x=> x.Name.Equals(name)))
  62. {
  63. person.CommentList.Add(comments);
  64. }
  65.  
  66. input2 = Console.ReadLine();
  67. }
  68.  
  69. foreach (var person in groupsList.OrderBy(x=> x.Name))
  70. {
  71. Console.WriteLine(person.Name);
  72. Console.WriteLine("Comments:");
  73. foreach (var comment in person.CommentList)
  74. {
  75. Console.WriteLine($"- {comment}");
  76. }
  77. Console.WriteLine("Dates attended:");
  78. foreach (var date in person.AttendeDateTimes.OrderBy(x=> x.Date))
  79. {
  80. string dates = date.ToString("dd/MM/yyyy");
  81. Console.WriteLine($"-- {dates}");
  82. }
  83. }
  84.  
  85.  
  86.  
  87. }
  88. }
  89.  
  90. class Person
  91. {
  92. public string Name { get; set; }
  93.  
  94. public List<DateTime> AttendeDateTimes { get; set; }
  95.  
  96. public List<string> CommentList { get; set; }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement