Пример #1
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 12)
         Console.WriteLine(string.Format("当前上午时间 {0} 点", w.Hour));
     else
     { 
         w.SetState(new NooState());
         w.WriteProgram();
     }
 }
Пример #2
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 17)
     {
         Console.WriteLine("当前时间:{0},下午工作状态还可以,继续努力", w.Hour);
     }
     else
     {
         w.SetState(new EveningState());
         w.WriteProgram();
     }
 }
Пример #3
0
 public override void WriteProgram(Work w)
 {
     if (w.Hour < 13)
     {
         Console.WriteLine("当前时间:{0} 点,饿了,困了,午休");
     }
     else
     {
         w.SetState(new AfterNoonState());
         w.WriteProgram();
     }
 }
Пример #4
0
        static void Main(string[] args)
        {
            //ConcreteDecoratorA a = new ConcreteDecoratorA();
            //ConcreteDecoratorC c = new ConcreteDecoratorC();
            //ConcreteDecoratorB b = new ConcreteDecoratorB();

            //a.SetComponent(b);
            //b.SetComponent(c);

            //a.Operation();

            //Console.Read();

            //Student stu = new Student() { Name = "Jasper", Age = 25, Friend = new Friend { Name ="York" } };
            //var stu2 = stu.Clone();
            //((Student)stu2).Age = 18;
            //((Student)stu2).Friend.Name = "Sean";

            Work w = new Work(new ForenoonState());
            w.Hour = 15;
            w.WriteProgram();
            Console.Read();
        }
Пример #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 override void WriteProgram(Work w)
 {
     Console.WriteLine("当前时间:{0},需要休息了", w.Hour);
 }
Пример #7
0
 public abstract void WriteProgram(Work w);