//Client Code static void Main_11(string[] args) { ConcreteVehicleFactory factoryMethod = new ConcreteVehicleFactory(); IDrive vehicle = factoryMethod.GetVehicleKm(VehicleType.Car); vehicle.Drive(); }
/// <summary> /// called often, must return promptly. It is a thread safe function. /// </summary> public override void Process() { StartedLoop(); // every cycle we create new behaviorData, populating it with existing data objects: IBehaviorData behaviorData = new BehaviorData() { sensorsData = this.currentSensorsData, robotState = this.robotState, robotPose = this.robotPose }; // use sensor data to update robotPose: robotSlam.EvaluatePoseAndState(behaviorData, driveController); // populate all behaviors with current behaviorData: foreach (ISubsumptionTask task in subsumptionTaskDispatcher.Tasks) { BehaviorBase behavior = task as BehaviorBase; if (behavior != null) { behavior.behaviorData = behaviorData; } } subsumptionTaskDispatcher.Process(); // calls behaviors, which take sensor outputs, and may compute drive inputs // look at ActiveTasksCount - it is an indicator of behaviors completed or removed. Zero count means we may need new behaviors combo. MonitorDispatcherActivity(); // when active behavior is waiting (yielding), no action items are computed. // otherwise driveInputs will be non-null: if (behaviorData.driveInputs != null) { //Debug.WriteLine("ShortyTheRobot: Process() - have drive inputs V=" + behaviorData.driveInputs.velocity + " Omega=" + behaviorData.driveInputs.omega); driveController.driveInputs = behaviorData.driveInputs; driveController.Drive(); // apply driveInputs to motors robotState.velocity = behaviorData.driveInputs.velocity; robotState.omega = behaviorData.driveInputs.omega; } this.BehaviorData = behaviorData; // for tracing sensorsController.Process(); // let sensorsController do maintenance EndingLoop(); }
static void Main(string[] args) { Human human = new Human(); Student student = new Student(); Robot robot = new Robot(); Car car = new Car(); Bicycle bicycle = new Bicycle(); // ------------------------------------------------------------ // Using objects as interfaces // ------------------------------------------------------------ IDrive iDrive = student; iDrive.Drive(car); iDrive.Drive(bicycle); // Vinicio - now change this to a robot // ------------------------------------------------------------ ISpeak[] interfaceArray = new ISpeak[3]; interfaceArray[0] = human; interfaceArray[1] = student; interfaceArray[2] = robot; Conference(interfaceArray); }
//自動車を運転する static void DriveACar(IDrive car) { car.Drive(); //car.Maintain(); }
public void Drive() { DriveMethod.Drive(); }