Advertisement
Guest User

Untitled

a guest
May 15th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Mentor_Group
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. List<Student> students = new List<Student>();
  16. Student student = new Student();
  17.  
  18.  
  19.  
  20. while (true)
  21. {
  22. string input = Console.ReadLine();
  23. if (input == "end of dates")
  24. {
  25. break;
  26. }
  27. string[] clientInfo = input.Split(' ', ',');
  28.  
  29.  
  30. List<DateTime> dates = new List<DateTime>();
  31.  
  32. for (int i = 1; i < clientInfo.Length;i++ )
  33. {
  34.  
  35. dates.Add(DateTime.ParseExact(clientInfo[i],"dd/MM/yyyy", CultureInfo.InvariantCulture));
  36. }
  37.  
  38. student.name = clientInfo[0];
  39. student.attendanceDate = dates;
  40.  
  41. }
  42. while (true)
  43. {
  44. string input2 = Console.ReadLine();
  45. if (input2 == "end of comments")
  46. {
  47. break;
  48. }
  49. string[] clientInfo = input2.Split('-');
  50.  
  51. var comments = clientInfo[1];
  52. student.comments.Add(comments);
  53.  
  54. }
  55. students.Add(student);
  56.  
  57. PrintResults(students);
  58.  
  59. }
  60. private static void PrintResults(List<Student> studentsGroup)
  61. {
  62. foreach (var student in studentsGroup.OrderBy(x=>x.name))
  63. {
  64. Console.WriteLine(student.name);
  65. Console.WriteLine("Comments:");
  66. if (student.comments.Count > 0)
  67. {
  68. Console.WriteLine("- " + string.Join("\n- ", student.comments));
  69. }
  70. Console.WriteLine("Dates attended:");
  71. if (student.attendanceDate.Count > 0)
  72. {
  73. foreach (var date in student.attendanceDate.OrderBy(x=>x.Date))
  74. {
  75. Console.WriteLine($"-- {0:dd/MM/yyyy}",student.attendanceDate);
  76. }
  77. }
  78. }
  79. }
  80. class Student
  81. {
  82. public List<string> comments { get; set; }
  83. public List<DateTime> attendanceDate { get; set; }
  84. public string name { get; set; }
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement