Beispiel #1
0
        static void Main(string[] args)
        {
            Context context = new Context();

            context.setState(new BlueState());

            context.pull();
            context.pull();
            context.pull();
            context.pull();
            context.pull();
            Console.ReadLine();
        }
Beispiel #2
0
 public void doAction(Context context)
 {
     Console.WriteLine("Player is in stop state");
     context.setState(this);
 }
 public void handle(Context context)
 {
     Console.WriteLine("State B");
     context.setState(this);
 }
Beispiel #4
0
 public override void handlepush(Context c)
 {
     Console.WriteLine("变成蓝色");
     c.setState(new BlueState());
 }
Beispiel #5
0
 public override void handlepull(Context c)
 {
     Console.WriteLine("变成绿色");
     c.setState(new GreenState());
 }
Beispiel #6
0
 public override void handlepull(Context c)
 {
     Console.WriteLine("变成黑色");
     c.setState(new BlackState());
 }