Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Globalization;
- namespace MentorGroup
- {
- class Student
- {
- public string Name { get; set; }
- public List<DateTime> Attendance { get; set; }
- public List<string> Comments { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- var students = new Dictionary<string, Student>();
- string input = Console.ReadLine();
- while (input != "end of dates")
- {
- string[] nameAndDates = input.Split(' ');
- string name = nameAndDates[0];
- List<string> dates = new List<string>();
- dates = nameAndDates[1].Split(',').ToList();
- Student student = new Student();
- student.Name = name;
- student.Attendance = new List<DateTime>();
- student.Comments = new List<string>();
- foreach (var data in dates)
- {
- student.Attendance.Add(DateTime.ParseExact(data, "dd/MM/yyyy", CultureInfo.InvariantCulture));
- }
- if (students.ContainsKey(name) == false)
- {
- students.Add(name, student);
- }
- else
- {
- students[name].Attendance.AddRange(student.Attendance);
- }
- input = Console.ReadLine();
- }
- input = Console.ReadLine();
- while (input != "end of comments")
- {
- var namesAndComments = input.Split('-');
- string currentName = namesAndComments[0];
- string comment = namesAndComments[1];
- if (students.ContainsKey(currentName))
- {
- students[currentName].Comments.Add(comment);
- }
- input = Console.ReadLine();
- }
- foreach (var student in students.OrderBy(x => x))
- {
- Console.WriteLine(student.Key);
- Console.WriteLine("Comments:");
- foreach (var comment in student.Value.Comments)
- {
- Console.WriteLine($"- {comment}");
- }
- Console.WriteLine("Dates attended:");
- foreach (var date in student.Value.Attendance.OrderBy(x => x))
- {
- Console.WriteLine($"-- {date.Day}/{date.Month}/{date.Year}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement