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.Globalization;
- namespace Prob_08_Mentor_Group
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- List<Mentor> Mentors = new List<Mentor>();
- List<string> MentorsName = new List<string>();
- List<Coment> Coments = new List<Coment>();
- InputMentors(Mentors, MentorsName);
- InputComents(MentorsName, Coments);
- Output(Mentors, MentorsName, Coments);
- }
- static void Output(List<Mentor> Mentors, List<string> MentorsName, List<Coment> Coments)
- {
- foreach (var mentorName in MentorsName)
- {
- Console.WriteLine("{0}", mentorName);
- Console.WriteLine("Comments:");
- foreach (var coment in Coments.Where(a => a.MentorName == mentorName))
- {
- Console.WriteLine("- {0}", coment.ComentText);
- }
- Console.WriteLine("Dates attended:");
- foreach (var mentor in Mentors.Where(a => a.Name == mentorName))
- {
- mentor.Dates.Sort();
- foreach (var date in mentor.Dates)
- {
- Console.WriteLine("-- {0:dd/MM/yyyy}", date);
- }
- }
- }
- }
- static void InputComents(List<string> MentorsName, List<Coment> Coments)
- {
- var firstLine = Console.ReadLine();
- while (firstLine != "end of comments")
- {
- var line = firstLine.Split(new char[] { '-' }).ToList();
- if (MentorsName.Contains(line[0]))
- {
- if (line.Count != 1)
- {
- Coments.Add(new Coment(line[0], line[1]));
- }
- }
- firstLine = Console.ReadLine();
- }
- }
- static void InputMentors(List<Mentor> Mentors, List<string> MentorsName)
- {
- var firstLineMentor = Console.ReadLine();
- while (firstLineMentor != "end of dates")
- {
- var line = firstLineMentor.Split(new char[] { ' ', ',' }).ToList();
- int kk2 = MentorsName.IndexOf(line[0]);
- List<DateTime> kk = new List<DateTime>();
- for (int i = 1; i < line.Count; i++)
- {
- if (kk2 == -1)
- {
- kk.Add(DateTime.ParseExact(line[i], "dd/MM/yyyy", CultureInfo.InvariantCulture));
- }
- else
- {
- Mentors[kk2].Dates.Add(DateTime.ParseExact(line[i], "dd/MM/yyyy", CultureInfo.InvariantCulture));
- }
- }
- if (kk2 == -1)
- {
- Mentors.Add(new Mentor(line[0], kk));
- MentorsName.Add(line[0]);
- }
- firstLineMentor = Console.ReadLine();
- }
- }
- }
- class Coment
- {
- public Coment(string mentorName, string comentText)
- {
- this.MentorName = mentorName;
- this.ComentText = comentText;
- }
- public string MentorName { get; set; }
- public string ComentText { get; set; }
- }
- class Mentor
- {
- public Mentor(string name, List<DateTime> dates)
- {
- this.Name = name;
- this.Dates = dates;
- }
- public string Name { get; set; }
- public List<DateTime> Dates { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement