示例#1
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();
         }
     }
 }
示例#2
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("时间:{0},精力充沛", w.Hour);
     }
     else
     {
         w.State = new NoonState();
         w.DoWork();
     }
 }
示例#3
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("时间:{0},下午想睡觉", w.Hour);
     }
     else
     {
         w.State = new EvningState();
         w.DoWork();
     }
 }
示例#4
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("时间:{0},饿了,午饭快点来吧", w.Hour);
     }
     else
     {
         w.State = new AfternooState();
         w.DoWork();
     }
 }
示例#5
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();
        }