public void Drive(IDrivable vehivle) { vehivle.Start(); vehivle.Accelerate(); vehivle.Brake(); vehivle.Stop(); }
private static void DriveOrRefuelVehicle(IDrivable car, IDrivable truck, string[] input, string command, double thirdParameter) { switch (command) { case "Drive": if (input[1] == "Car") { car.Drive(thirdParameter); } else if (input[1] == "Truck") { truck.Drive(thirdParameter); } break; case "Refuel": if (input[1] == "Car") { car.Refuel(thirdParameter); } else if (input[1] == "Truck") { truck.Refuel(thirdParameter); } break; default: throw new ArgumentException("Invalid vehicle!"); } }
public void Drive(IDrivable vehicle) { Console.WriteLine("Take it easy. I'm just learnig to drive"); vehicle.Start(); vehicle.ChangeOrientation(45); vehicle.ChangeOrientation(-45); vehicle.Stop(); }
public void Drive(IDrivable drivable) { Console.WriteLine("I'm about to drive!"); drivable.Start(); Console.WriteLine("I'm about to turn"); drivable.ChangeOrientation(45); Console.WriteLine("I'm about to stop"); drivable.Stop(); }
/// <summary> /// Test Method Driving Van and Car AroundTheBlock /// </summary> /// <param name="d">IDrivable</param> public static void AroundTheBlock(IDrivable d) { d.Start(); d.Accelerate(); d.Turn("Right"); d.Turn("Right"); d.Turn("Right"); d.Turn("Right"); d.Decelerate(); d.Stop(); }
static void Main(string[] args) { #region OOP //Human amanda = new Human(); Student jeff = new Student("Jeff", "Jeff", 1, "401-dotnet-d2"); int x = 5; //StackHeap(x,jeff); Console.WriteLine(x); Console.WriteLine($"Jeff's age is: {jeff.Age}"); Human enrique = new Student("Enrique", "Kike", 2, "401-dotnet-d9"); //jeff.Live(); // Vinicio - somehow .NET knows that enrique is actually a student // and calls the right implementation for Live // POLYMORPHISM //enrique.Live(); Athlete mike = new Athlete("Mike", "Mike", 5, 3000, 2); CFStudent karina = new CFStudent("Karina", "Karina", 1); //PolymorphismInAction(new Human[] { jeff, enrique, mike, karina }); //karina.Think(); #endregion #region Interfaces DanceParty(karina, mike); #endregion #region Enums int January = 1; int February = 2; Month m = Month.April; //WorkingWithMonths(Month.April ,84884854); #endregion // IFly fly = new Airplane(); Airplane airplane = new Airplane(); IDrivable driveable = airplane; IFly iFly = airplane; Console.WriteLine($"is airplane an IFly? {airplane is IFly}"); Console.WriteLine($"is airplane an IDriveable? {airplane is IDrivable}"); Console.WriteLine($"is airplane an Airplane? {airplane is Airplane}"); Console.WriteLine($"is airplane an IDance? {airplane is IDance}"); }
public void RemoveFromRoad(IDrivable item) { if (obj.Contains(item)) { obj.Remove(item); } else { Console.WriteLine("Item not found"); } }
public void PutOnRoad(IDrivable item) { if (!obj.Contains(item)) { obj.Add(item); } else { Console.WriteLine("Item already exists"); } }
// AN ABSTRACT CLASS WOULD'VE BEEN A BETTER IDEA THAN AN INTERFACE IN THIS SITUATION static void Main(string[] args) { IDrivable car = GetCar(); IDrivable truck = GetTruck(); var n = int.Parse(Console.ReadLine()); ProcessInput(car, truck, n); PrintVehicleInfo(car, truck); }
static void Main(string[] args) { // SHOULD HAVE USED AN ABSTRACT CLASS VEHICLE INSTEAD OF AN INTERFACE IN ORDER TO REUSE ALOT OF THE METHODS. IDrivable car = null; IDrivable truck = null; Bus bus = null; GetVehicles(ref car, ref truck, ref bus); var n = int.Parse(Console.ReadLine()); ProcessInput(car, truck, bus, n); PrintVehicleStatus(car, truck, bus); }
public void SetupVehicleManager() { // Debug.LogWarning("Vehicle Health Manager has not been fully ported to the new PhysX system"); gamestateTracker = FindObjectOfType <GamestateTracker>(); gamestateTrackerPhotonView = gamestateTracker.GetComponent <PhotonView>(); networkManager = FindObjectOfType <NetworkManager>(); maxHealth = health; rb = GetComponent <PhysXRigidBody>(); icd = GetComponent <InterfaceCarDrive>(); icd4 = GetComponent <InterfaceCarDrive4W>(); carDriver = icd.GetComponent <IDrivable>(); inputDriver = GetComponent <InputDriver>(); myPhotonView = GetComponent <PhotonView>(); npv = GetComponent <NetworkPlayerVehicle>(); announcerManager = FindObjectOfType <AnnouncerManager>(); _rammingDetails = new Weapon.WeaponDamageDetails(null, 0, 0, Weapon.DamageType.ramming, 0, Vector3.zero); for (int i = 0; i < collisionAreas.Count; i++) { CollisionArea collisionArea = collisionAreas[i]; collisionArea.rotation.eulerAngles = collisionArea.rotationEuler; collisionAreas[i] = collisionArea; } defaultDrag = rb.linearDamping; defaultAngularDrag = rb.angularDamping; playerTransformTracker = FindObjectOfType <PlayerTransformTracker>(); PlayerEntry player = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber); if (player.teamId == teamId) { tutorials.SetActive(true); } else { tutorials.SetActive(false); } player.Release(); }
private static void ProcessInput(IDrivable car, IDrivable truck, Bus bus, int n) { for (int i = 0; i < n; i++) { var input = Console.ReadLine().Split(); var command = input[0]; var vehicleType = input[1]; var thirdParameter = double.Parse(input[2]); try { DriveOrRefuelVehicle(car, truck, bus, input, command, thirdParameter); } catch (Exception e) { Console.WriteLine(e.Message); } } }
private static void GetVehicles(ref IDrivable car, ref IDrivable truck, ref Bus bus) { for (int i = 0; i < 3; i++) { IDrivable currentVehicle = null; var vehicleInput = Console.ReadLine().Split(); currentVehicle = GetVehicle(vehicleInput); if (currentVehicle is Car) { car = currentVehicle; } else if (currentVehicle is Truck) { truck = currentVehicle; } else if (currentVehicle is Bus) { bus = (Bus)currentVehicle; } } }
private void Awake() { // Debug.LogWarning("AI control needs porting to new PhysX system."); // return; // get the car controller reference myRb = GetComponent <PhysXRigidBody>(); interfaceCarDrive = GetComponent <InterfaceCarDrive4W>(); // give the random perlin a random value m_RandomPerlin = Random.value * 100; m_Rigidbody = GetComponent <Rigidbody>(); CarDriver = interfaceCarDrive.GetComponent <IDrivable>(); m_Driving = true; WaypointCircuit wpc = FindObjectOfType <WaypointCircuit>(); if (wpc != null) { circuitFound = true; } }
void IDrive.Drive(IDrivable vehicle) { Console.WriteLine("console.log(I can drive better than any human)"); vehicle.Start(); vehicle.Stop(); }
public DrivingController(IDrivable drivable) { _drivable = drivable; }
static void InterfaceExample(IDrivable drivable) { drivable.Accelerate(); }
// This method does not care WHO the drivre is or WHAT is being driven...as long as the min requiremetns for each interface are met. static void DriveTheCar(IDrivable vehicle, IDrive driver) { vehicle.Start(driver); }
static void DrivableExample(IDrivable drivable, IDrive driver) { drivable.Start(driver); }
public void Drive(IDrivable drivable) { drivable.Start(); drivable.Accelerate(); }
public static void GoForward(IDrivable d) { d.Start(); d.Accelerate(); d.Decelerate(); }
string Drive(IDrivable drivable) { drivable.Accelerate(); drivable.Brake(); return("I Drove!"); }
private static void PrintVehicleStatus(IDrivable car, IDrivable truck, Bus bus) { Console.WriteLine(car); Console.WriteLine(truck); Console.WriteLine(bus); }
private static void PrintVehicleInfo(IDrivable car, IDrivable truck) { Console.WriteLine(car); Console.WriteLine(truck); }