예제 #1
0
        public Conference Schedule()
        {
            String       line   = string.Empty;
            List <Event> events = new List <Event>();

            while (true) // Loop indefinitely
            {
                ////Console.WriteLine("Enter input:"); // Prompt
                line = Console.ReadLine();                            // Get string from user
                if (line == "exit" || line == "" || line.Length <= 0) // Check string
                {
                    Console.WriteLine("input will end with exit or blank space");
                    break;
                }
                line = line.Trim();
                Event event_obj = ParseInputLine(line);
                if (event_obj == null)
                {
                    continue;
                }
                events.Add(event_obj);
            }

            Conference conference = new Conference();

            while (events.Count != 0)
            {
                DurationUnit unit        = new DurationUnit();
                Slot         morningSlot = new Slot(Config.MORNING_SLOT_DURATION, Config.MORNING_SLOT_START_TIME);
                fillSlotWithEvents(morningSlot, events);
                Slot lunchSlot = new Slot(Config.LUNCH_SLOT_DURATION, Config.LUNCH_SLOT_START_TIME);
                unit.Minutes();
                lunchSlot.addEvent(new Event("Lunch", Config.LUNCH_SLOT_DURATION, unit));
                Slot afternoonSlot = new Slot(Config.AFTERNOON_SLOT_DURATION, Config.AFTERNOON_SLOT_START_TIME);
                fillSlotWithEvents(afternoonSlot, events);
                Event networkingEvent = new Event(Config.NETWORKING_EVENT_NAME, Config.NETWORKING_EVENT_DURATION, unit);
                Slot  networkingSlot  = new Slot(networkingEvent.GetDurationInMinutes(),
                                                 Config.NETWORKING_EVENT_MIN_START_TIME);
                networkingSlot.addEvent(networkingEvent);
                afternoonSlot.addSupplementSlot(networkingSlot);
                Track track = new Track();
                track.addSlot(morningSlot);
                track.addSlot(lunchSlot);
                track.addSlot(afternoonSlot);
                conference.addTrack(track);
            }

            return(conference);
        }