示例#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 = 15;
            emergencyProjects.WriteProgram();
            emergencyProjects.Hour = 17;
            emergencyProjects.WriteProgram();

            emergencyProjects.TaskFinished = false;

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

            Console.Read();
        }
示例#2
0
 public override void WriteProgram(Work w)
 {
     if (w.Finish)
     {
         w.SetState(new RestState());
         w.WriteProgram();
     }
     else
     {
         if (w.Hour < 21)
         {
             Console.WriteLine("当前时间:{0}点 加班哦,疲累之极",w.Hour);
         }
         else
         {
             w.SetState(new SleepingState());
             w.WriteProgram();
         }
     }
 }
示例#3
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 13)
     {
         System.Console.WriteLine($"当前时间:{work.Hour}点,午休会");
     }
     else
     {
         work.SetState(new AfternoonState());
         work.WriteProgram();
     }
 }
示例#4
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 12)
     {
         System.Console.WriteLine($"当前时间:{work.Hour}点,开始工作");
     }
     else
     {
         work.SetState(new NonnState());
         work.WriteProgram();
     }
 }
示例#5
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点,饿了,午饭:犯困,午休.", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
示例#6
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 17)
     {
         Console.WriteLine($"當前時間: {work.Hour}點 下午狀態還不錯,繼續努力");
     }
     else
     {
         work.SetState(new EveningState());
         work.WriteProgram();
     }
 }
示例#7
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 17)
     {
         System.Console.WriteLine($"当前时间:{work.Hour}点,有点困");
     }
     else
     {
         work.SetState(new EveningState());
         work.WriteProgram();
     }
 }
示例#8
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("当前时间:{0}点 上午工作,精神百倍",w.Hour);
     }
     else
     {
         w.SetState(new NoonState());
         w.WriteProgram();
     }
 }
示例#9
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine($"当前时间:{w.Hour}点 饿了,午饭,犯困,午休");
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
示例#10
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点 饿了,午饭:犯困,午休。", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
示例#11
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("当前时间:{0}点 下午状态还不错,继续努力",w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
示例#12
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("当前时间:{0}点 下午状态还不错,继续努力", w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
示例#13
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点 饿了,午饭;犯困,午休。", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
示例#14
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("当前时间:{0}点 上午工作,精神百倍", w.Hour);
     }
     else
     {
         w.SetState(new NoonState());
         w.WriteProgram();
     }
 }
示例#15
0
        static void Main(string[] args)
        {
            Work project = new Work();

            project.Hour = 9;
            project.WriteProgram();

            project.Hour = 10;
            project.WriteProgram();

            project.Hour = 12;
            project.WriteProgram();

            project.Hour = 13;
            project.WriteProgram();

            project.Hour = 14;
            project.WriteProgram();

            project.Hour = 17;

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

            project.WriteProgram();

            project.Hour = 19;
            project.WriteProgram();

            project.Hour = 22;
            project.WriteProgram();

            Console.WriteLine("\n");

            Context context = new Context(new ConcreteStateA());

            // 不斷的請求,同時更改狀態
            context.Request();
            context.Request();
            context.Request();
            context.Request();

            Console.ReadLine();
        }
示例#16
0
        static void Main(string[] args)
        {
            #region 基本用法(Basic.cs)
            Context c = new Context(new ConcreteStateA());

            c.Request();
            c.Request();
            c.Request();
            c.Request();
            #endregion

            #region 具体实例(Example.cs)
            //紧急项目
            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.Finish = false;

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

            Console.Read();
            #endregion
        }
示例#17
0
        static void Main(string[] args)
        {
            #region 基本用法(Basic.cs)
            Context c = new Context(new ConcreteStateA());

            c.Request();
            c.Request();
            c.Request();
            c.Request();
            #endregion

            #region 具体实例(Example.cs)
            //紧急项目
            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.Finish = false;

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

            Console.Read();
            #endregion
        }
示例#18
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Work work = new Work();

            work.Hour = 9;
            work.WriteProgram();

            work.Hour = 10;
            work.WriteProgram();

            work.Hour = 12;
            work.WriteProgram();

            work.Hour = 13;
            work.WriteProgram();

            work.Hour = 14;
            work.WriteProgram();

            work.Hour = 17;

            work.TaskFinished = true;
            //work.TaskFinished = false;
            work.WriteProgram();

            work.Hour = 19;
            work.WriteProgram();


            work.Hour = 22;
            work.WriteProgram();


            Console.Read();
        }