コード例 #1
0
        public static DailySchedule operator+(DailySchedule d1, DailySchedule d2)
        {
            DailySchedule d3 = new DailySchedule()
            {
                Day = d1.Day + " + " + d2.Day
            };
            int currentTime = 0;

            foreach (DailyItem item in d1.dailyItems)
            {
                d3.dailyItems.Add(new DailyItem(new Time(currentTime), new Time((item.EndTime - item.StartTime) + currentTime), item.Info, item.Readyness));
                currentTime += item.EndTime - item.StartTime;
            }
            foreach (DailyItem item1 in d2.dailyItems)
            {
                foreach (DailyItem item2 in d3.dailyItems)
                {
                    if (item2.Info == item1.Info)
                    {
                        d3.dailyItems.Remove(item2);
                        break;
                    }
                }
            }
            foreach (DailyItem item in d2.dailyItems)
            {
                d3.dailyItems.Add(new DailyItem(new Time(currentTime), new Time((item.EndTime - item.StartTime) + currentTime), item.Info, item.Readyness));
                currentTime += item.EndTime - item.StartTime;
            }
            return(d3);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            DailySchedule ds = new DailySchedule()
            {
                Day = "Monday"
            };

            ds.AddDailyItem(new DailyItem(new Time("6:00:00"), new Time("6:15:00"), "Проснуться", false));
            ds.AddDailyItem(new DailyItem(new Time("6:14:00"), new Time("6:40:00"), "Приговить и поесть", false));
            ds.AddDailyItem(new DailyItem(new Time("6:15:00"), new Time("6:40:00"), "Приговить и поесть", false));
            ds.Display();

            ds.RemoveDailyItem("Проснуться");
            ds.Display();

            ds.EditRemoveDailyItem("Приговить и поесть", "Почистить зубы", false);
            ds.Display();

            DailyItem di = ds.FindFreeTime(new Time("2:00:00"), new Time("8:00:00"), new Time("10:00:00"));

            di.Display();

            Console.WriteLine("\n\n\n\n\n             Redo");
            ds.DoRedo().Display();

            DailySchedule ds1 = new DailySchedule()
            {
                Day = "Monday"
            };

            ds.AddDailyItem(new DailyItem(new Time("6:00:00"), new Time("6:15:00"), "Проснуться", false));
            ds1.AddDailyItem(new DailyItem(new Time("6:00:00"), new Time("6:15:00"), "Проснуться", false));
            ds1.AddDailyItem(new DailyItem(new Time("6:15:00"), new Time("6:30:00"), "Приговить", false));
            ds1.AddDailyItem(new DailyItem(new Time("6:15:00"), new Time("6:40:00"), "Поесть", false));
            ds1.AddDailyItem(new DailyItem(new Time("6:40:00"), new Time("6:50:00"), "Почистить зубы", false));
            (ds + ds1).Display();
        }