Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Mentor_Group
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Student> students = new List<Student>();
- Student student = new Student();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "end of dates")
- {
- break;
- }
- string[] clientInfo = input.Split(' ', ',');
- List<DateTime> dates = new List<DateTime>();
- for (int i = 1; i < clientInfo.Length;i++ )
- {
- dates.Add(DateTime.ParseExact(clientInfo[i],"dd/MM/yyyy", CultureInfo.InvariantCulture));
- }
- student.name = clientInfo[0];
- student.attendanceDate = dates;
- }
- while (true)
- {
- string input2 = Console.ReadLine();
- if (input2 == "end of comments")
- {
- break;
- }
- string[] clientInfo = input2.Split('-');
- var comments = clientInfo[1];
- student.comments.Add(comments);
- }
- students.Add(student);
- PrintResults(students);
- }
- private static void PrintResults(List<Student> studentsGroup)
- {
- foreach (var student in studentsGroup.OrderBy(x=>x.name))
- {
- Console.WriteLine(student.name);
- Console.WriteLine("Comments:");
- if (student.comments.Count > 0)
- {
- Console.WriteLine("- " + string.Join("\n- ", student.comments));
- }
- Console.WriteLine("Dates attended:");
- if (student.attendanceDate.Count > 0)
- {
- foreach (var date in student.attendanceDate.OrderBy(x=>x.Date))
- {
- Console.WriteLine($"-- {0:dd/MM/yyyy}",student.attendanceDate);
- }
- }
- }
- }
- class Student
- {
- public List<string> comments { get; set; }
- public List<DateTime> attendanceDate { get; set; }
- public string name { get; set; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement