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.State = new AfternooState(); w.DoWork(); } }
public override void WriteProgram(Work w) { if (w.Hour < 12) { Console.WriteLine("时间:{0},精力充沛", w.Hour); } else { w.State = new NoonState(); w.DoWork(); } }
public override void WriteProgram(Work w) { if (w.Hour < 13) { Console.WriteLine("时间:{0},下午想睡觉", w.Hour); } else { w.State = new EvningState(); w.DoWork(); } }
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.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.Finished) { w.State = new RestState(); w.DoWork(); } else { if (w.Hour < 21) { Console.WriteLine("时间:{0},加班",w.Hour); } else { w.State = new SleepingState(); w.DoWork(); } } }
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); }
static void Main(string[] args) { Work w = new Work(); w.Finished = false; w.Hour = 9; w.State = new ForenoonState(); w.DoWork(); w.Hour = 10; w.DoWork(); w.Hour = 13; w.DoWork(); w.Hour = 15; w.DoWork(); w.Hour = 22; w.DoWork(); }
public override void WriteProgram(Work w) { Console.WriteLine("当前时间:{0}点 不行了,睡着了。", w.Hour); }
public abstract void WriteProgram(Work w);
public override void WriteProgram(Work w) { Console.WriteLine("当前时间:{0}点下班回家了", w.Hour); }