示例#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.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
示例#3
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("當前時間:{0}點 下午狀態還不錯,繼續努力", w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
示例#4
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("當前時間:{0}點 上午工作,精神百倍", w.Hour);
     }
     else
     {
         w.SetState(new NoonState());
         w.WriteProgram();
     }
 }
示例#5
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();
         }
     }
 }
示例#6
0
 public abstract void WriteProgram(Work w);
示例#7
0
 public override void WriteProgram(Work w)
 {
     Console.WriteLine("當前時間:{0}點 不行了,睡著了。", w.Hour);
 }
示例#8
0
 public abstract void WriteProgram(Work w);
示例#9
0
 public override void WriteProgram(Work w)
 {
     Console.WriteLine("當前時間:{0}點 下班回家了", w.Hour);
 }