static void Main(string[] args) { var context = new Context(new DuckState(), Season.Duck); for (int i = 0; i < 5; i++) { context.Request(); Console.WriteLine("Current season: {0} season", context.CurrentSeason.ToString()); } Console.ReadKey(true); }
protected void SetSeason(Context context, Season season) { // Even though this setter is private // it can be accessed from this nested class context.CurrentSeason = season; }
protected void SetState(Context context, State state) { // Even though this variable is private // it can be modified from this nested class context.currentState = state; }
public abstract void Handle(Context context);