Ejemplo n.º 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();
        }
Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 3
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 13)
     {
         System.Console.WriteLine($"当前时间:{work.Hour}点,午休会");
     }
     else
     {
         work.SetState(new AfternoonState());
         work.WriteProgram();
     }
 }
Ejemplo n.º 4
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 12)
     {
         System.Console.WriteLine($"当前时间:{work.Hour}点,开始工作");
     }
     else
     {
         work.SetState(new NonnState());
         work.WriteProgram();
     }
 }
Ejemplo n.º 5
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点,饿了,午饭:犯困,午休.", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 6
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 17)
     {
         Console.WriteLine($"當前時間: {work.Hour}點 下午狀態還不錯,繼續努力");
     }
     else
     {
         work.SetState(new EveningState());
         work.WriteProgram();
     }
 }
Ejemplo n.º 7
0
 public override void WriteProgram(Work work)
 {
     if (work.Hour < 17)
     {
         System.Console.WriteLine($"当前时间:{work.Hour}点,有点困");
     }
     else
     {
         work.SetState(new EveningState());
         work.WriteProgram();
     }
 }
Ejemplo n.º 8
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("当前时间:{0}点 上午工作,精神百倍",w.Hour);
     }
     else
     {
         w.SetState(new NoonState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 9
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine($"当前时间:{w.Hour}点 饿了,午饭,犯困,午休");
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 10
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点 饿了,午饭:犯困,午休。", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 11
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("当前时间:{0}点 下午状态还不错,继续努力",w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 12
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("当前时间:{0}点 下午状态还不错,继续努力", w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 13
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0}点 饿了,午饭;犯困,午休。", w.Hour);
     }
     else
     {
         w.SetState(new AfternoonState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 14
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
     {
         Console.WriteLine("当前时间:{0}点 上午工作,精神百倍", w.Hour);
     }
     else
     {
         w.SetState(new NoonState());
         w.WriteProgram();
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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();
        }