コード例 #1
0
        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);
        }
コード例 #2
0
 protected void SetSeason(Context context, Season season)
 {
     // Even though this setter is private
     // it can be accessed from this nested class
     context.CurrentSeason = season;
 }
コード例 #3
0
 protected void SetState(Context context, State state)
 {
     // Even though this variable is private
     // it can be modified from this nested class
     context.currentState = state;
 }
コード例 #4
0
 public abstract void Handle(Context context);