示例#1
0
        static void Main(string[] args)
        {
            //紧急项目
            Work emergencyProjects = new Work();
            emergencyProjects.Hour = 9;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 10;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 12;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 13;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 14;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 17;

            //emergencyProjects.WorkFinished = true;
            emergencyProjects.TaskFinished = false;

            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 19;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 22;
            emergencyProjects.WriteProgram();

            Console.Read();
        }
示例#2
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("时间:{0},饿了,午饭快点来吧", w.Hour);
     }
     else
     {
         w.State = new AfternooState();
         w.DoWork();
     }
 }
示例#3
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("时间:{0},精力充沛", w.Hour);
     }
     else
     {
         w.State = new NoonState();
         w.DoWork();
     }
 }
示例#4
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("时间:{0},下午想睡觉", w.Hour);
     }
     else
     {
         w.State = new EvningState();
         w.DoWork();
     }
 }
示例#5
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("当前时间:{0}点 上午工作,精神百倍", w.Hour);
     }
     else
     {
         w.SetState(new NoonState());
         w.WriteProgram();
     }
 }
示例#6
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点 饿了,午饭;犯困,午休。", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
示例#7
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("当前时间:{0}点 下午状态还不错,继续努力", w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
示例#8
0
 public override void WriteProgram(Work w)
 {
     if (w.Finished)
     {
         w.State = new RestState();
         w.DoWork();
     }
     else
     {
         if (w.Hour < 21)
         {
             Console.WriteLine("时间:{0},加班",w.Hour);
         }
         else
         {
             w.State = new SleepingState();
             w.DoWork();
         }
     }
 }
示例#9
0
 public override void WriteProgram(Work w)
 {
     if (w.TaskFinished)
     {
         w.SetState(new RestState());
         w.WriteProgram();
     }
     else
     {
         if (w.Hour < 21)
         {
             Console.WriteLine("当前时间:{0}点 加班哦,疲累之极", w.Hour);
         }
         else
         {
             w.SetState(new SleepingState());
             w.WriteProgram();
         }
     }
 }
示例#10
0
 public abstract void WriteProgram(Work w);
示例#11
0
 public override void WriteProgram(Work w)
 {
     Console.WriteLine("时间:{0},睡觉",w.Hour);
 }
示例#12
0
        static void Main(string[] args)
        {
            Work w = new Work();
            w.Finished = false;
            w.Hour = 9;
            w.State = new ForenoonState();
            w.DoWork();

            w.Hour = 10;
            w.DoWork();

            w.Hour = 13;
            w.DoWork();

            w.Hour = 15;
            w.DoWork();

            w.Hour = 22;
            w.DoWork();
        }
示例#13
0
 public override void WriteProgram(Work w)
 {
     Console.WriteLine("当前时间:{0}点 不行了,睡着了。", w.Hour);
 }
 public abstract void WriteProgram(Work w);
 public override void WriteProgram(Work w)
 {
     Console.WriteLine("当前时间:{0}点下班回家了", w.Hour);
 }