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