Пример #1
0
        public Conference(ConferneceDescriptor conferneceDescriptor)
        {
            _conferneceDescriptor = conferneceDescriptor;
            Tracks = new List<Track>();

            var talks = conferneceDescriptor.Talks.OrderByDescending(talk => talk.Duration).ToList();
            Tracks.Add(new Track(new Session(conferneceDescriptor.FirstSession)));

            foreach (var talk in talks)
            {
                var isTalkAdded = false;

                foreach (var track in Tracks)
                {
                    isTalkAdded = track.AddTalk(talk);
                    if (isTalkAdded)
                        break;
                }

                if (isTalkAdded) continue;

                foreach (var track in Tracks)
                {
                    if (track.Sessions.Count == 1)
                    {
                        track.AddSession(new Session(conferneceDescriptor.SecondSession));
                        isTalkAdded = track.AddTalk(talk);
                        if (isTalkAdded)
                            break;
                    }
                }

                if (!isTalkAdded)
                {
                    var newTrack = new Track(new Session(conferneceDescriptor.FirstSession));
                    Tracks.Add(newTrack);
                    isTalkAdded = newTrack.AddTalk(talk);
                }

                if (!isTalkAdded)
                    throw new Exception("talk cant addedd");
            }

            foreach (var track in Tracks)
            {
                track.AddLunchSession(new Session(conferneceDescriptor.LunchSession));
                track.AddNetworkEvent(conferneceDescriptor.NetworkEventStartTime);
                Console.WriteLine(track);
            }
        }
Пример #2
0
        private static void Main(string[] args)
        {
            var lines = File.ReadAllLines("TestInput.txt");

            //var talks = lines.Select(line => new Talk(line)).ToList();

            List<Talk> talks = (from line in lines where !string.IsNullOrWhiteSpace(line) select new Talk(line)).ToList();

            var conferneceDescriptor = new ConferneceDescriptor
            {
                FirstSession = new Session(new TimeSpan(9, 00, 0), 180),
                LunchSession = new Session(new TimeSpan(12, 00, 0), 60),
                SecondSession = new Session(new TimeSpan(13, 00, 0), 240),
                NetworkEventStartTime = new TimeSpan(16, 0, 0),
                Talks = talks
            };
            var conf = new Conference(conferneceDescriptor);

            Console.ReadLine();
        }