コード例 #1
0
 /*
  * It's your choice. You may prefer to use a setter
  * method instead of using a constructor.
  * You can call this method whenever we want
  * to change the "vehicle behavior" on the fly.
  */
 public void SetVehicleBehavior(VehicleBehavior behavior)
 {
     this.behavior = behavior;
 }
コード例 #2
0
 public Vehicle(string vehicleType)
 {
     this.vehicleType = vehicleType;
     //Setting the initial behavior
     this.behavior = new InitialBehavior();
 }