static void Entrance() { Console.WriteLine("Journey by airplane"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("\nJourney by car"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine("\nTesting polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); }
static void doWork() { Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("\nJourney by car:"); Car myCar = new Car(); myCar.StartEngine("RUM RUM brrrrm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut Phuttt.."); Console.WriteLine("\nTesting polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); }
static void doWork() { Console.WriteLine("Journey by Plane"); AirPlane plane = new AirPlane(); plane.StartEngine("ssssss.........."); plane.TakeOff(); plane.Drive(); plane.Land(); plane.StopEngine("brrr"); //plane = null; Console.WriteLine("Journey by Car"); Car car = new Car(); car.StartEngine("vrooom"); car.Accelerate(); car.Drive(); car.Brake(); car.StopEngine("bleeep"); //car = null; Vehicle v = car; v.Drive(); v = plane; v.Drive(); }
static void doWork() { Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Conctact"); myPlane.TakeOff(); myPlane.Drive(); //Drive() method in base class Vehicle and ovveriden method are not the same myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine(); Console.WriteLine("Journey by car:"); Car myCar = new Car(); myCar.StartEngine("brm brm"); myCar.Accelerate(); myCar.Drive(); //Drive() method in base class Vehicle and ovveriden method are not the same myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine("\nTesting polymorphism"); Vehicle v = myCar; //creating a reference to Car object by using a Vehicle variable v.Drive(); //calls Drive() method by using Vehicle variable (which is Motoring) v = myPlane; v.Drive(); // this is Flying }
static void doWork() { Console.WriteLine("Journey by airplane"); Airplane myFlight = new Airplane(); myFlight.StartEngine("Contact"); myFlight.TakeOff(); myFlight.Drive(); myFlight.Land(); myFlight.StopEngine("whirr"); Console.WriteLine(); Console.WriteLine("Journey by car"); Car myVW = new Car(); myVW.StartEngine("Loud Deisel Rumble"); myVW.Accelerate(); myVW.Drive(); myVW.Brake(); myVW.StopEngine("sad rumble"); Console.WriteLine("\nTesting polymorphism..."); Vehicle v = myVW; v.Drive(); v = myFlight; v.Drive(); }
private static void DoWork() { Console.WriteLine("Journey by airplane: "); Airplane airplane = new Airplane(); airplane.StartEngine("Contact"); airplane.TakeOff(); airplane.Drive(); airplane.Land(); airplane.StopEngine("Whirr"); Console.WriteLine(); Console.WriteLine("Journey by car: "); Car car = new Car(); car.StartEngine("Brm brm"); car.Accelerate(); car.Drive(); car.Brake(); car.StopEngine("Phut phut"); Console.WriteLine(); Vehicles v = car; v.Drive(); v = airplane; v.Drive(); }
static void doWork() { Console.WriteLine("Journey by airplane"); Airplane myAirplane = new Airplane(); myAirplane.StartEngine("Contact"); myAirplane.TakeOff(); myAirplane.Drive(); myAirplane.Land(); myAirplane.StopEngine("whirr"); Console.WriteLine("Journey by car"); Car myCar = new Car(); myCar.StartEngine("Vroom"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut Phut"); Console.WriteLine("\nTesting Polymorphism"); Vehicle v = myCar; v.Drive(); v = myAirplane; v.Drive(); }
static void doWork() { // TODO: Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("\nJourney by car:"); Car myCar = new Car(); myCar.StartEngine("Brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut"); Console.WriteLine("\nTesting polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); }
static void doWork() { Console.WriteLine("This is the Vehicles Lab."); Console.WriteLine("=============================================================="); Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("=============================================================="); Console.WriteLine("Journey by car:"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine("=============================================================="); Console.WriteLine("Journey by truck:"); Truck tyra = new Truck(); tyra.StartEngine("Vroom Vroom"); tyra.Haul(); tyra.Drive(); tyra.Tows(); tyra.StopEngine("Klunk Klunk"); Console.WriteLine("=============================================================="); Console.WriteLine("Journey by boat:"); Boat Titantic = new Boat(); Titantic.StartEngine("Swish Swish"); Titantic.Sail(); Titantic.Drive(); Titantic.Floats(); Titantic.StopEngine("Glug Glug"); Console.WriteLine("=============================================================="); Console.WriteLine("Testing polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); v = tyra; v.Drive(); Console.WriteLine("=============================================================="); }
static void doWork() { Console.WriteLine("This is the vehicles lab."); Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine(); Console.WriteLine("======================================="); Console.WriteLine("Journey by car:"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine("======================================="); Console.WriteLine("Journey by truck:"); Truck steven = new Truck(); steven.StartEngine("Diesel Clatter"); steven.Accelerate(); steven.Drive(); steven.Brake(); steven.StopEngine("Clunk Clunk"); Console.WriteLine("======================================="); Console.WriteLine("Journey by boat:"); Boat titanic = new Boat(); titanic.StartEngine("Vroom Vroom"); titanic.Accelerate(); titanic.Drive(); titanic.Brake(); titanic.StopEngine("Glug Glug"); Console.WriteLine("======================================="); Console.WriteLine("\nTesting polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); v = steven; steven.Drive(); Console.WriteLine("======================================="); }
static void doWork() { Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); //making airplane class into myplane to call myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine(); Console.WriteLine("Journey by car:"); Car myCar = new Car(); //making car class into mycar to call myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine(); Console.WriteLine("Journey by motorcycle"); Motorcycle R6 = new Motorcycle(); R6.StartEngine(" RROOOM ROOOOM"); R6.GOFAST(); R6.Drive(); R6.SKID(); R6.StopEngine("CLANK CLUNK CLANK"); Console.WriteLine(); Console.WriteLine("Journey by Cigarette Boat"); Boat Cigarette = new Boat(); Cigarette.StartEngine(" CHUG CHUG"); Cigarette.Swoosh(); Cigarette.Drive(); Cigarette.Whip(); Cigarette.StopEngine("It doesnt matter - tony"); Console.WriteLine(); Console.WriteLine("Journey by Vehicle"); Vehicle V = new Vehicle(); V.StartEngine("Start Engine"); V.Drive(); //virtual method, desginged to be overriden V.StopEngine("Stop ENgine"); }
static void doWork() { Console.WriteLine("This is lab Vehicles"); Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine(); Console.WriteLine("Journey by car:"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine("Journey by Motorcycle"); Console.WriteLine(); Motorcycle myMotorcycle = new Motorcycle(); myMotorcycle.StartEngine("Motorcycle noises"); myMotorcycle.Accelerate(); myMotorcycle.Drive(); myMotorcycle.Brake(); myMotorcycle.StopEngine("No Motorcycle noises"); Console.WriteLine(); Console.WriteLine("Journey by Boat"); Boat Titanic = new Boat(); Titanic.StartEngine("Glug Glug"); Titanic.Sail(); Titanic.Drive(); Titanic.Floats(); Titanic.StopEngine("Sinking Noises"); Console.WriteLine("\nTesting polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); v = myMotorcycle; v.Drive(); }
static void doWork() { Console.WriteLine("Test vehicle"); Vehicle v = new Vehicle(); v.StartEngine("RUM RUM"); v.Drive(); v.StopEngine("GIN GIN"); Console.WriteLine("------------------------------------"); Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); // prints "Flying" from Car class from overloaded method in Derived class Airplane. myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("------------------------------------"); Console.WriteLine("Journey by car:"); Car Car1 = new Car(); Car1.StartEngine("Brm brm"); Car1.Accelerate(); Car1.Drive(); // prints Motoring" Car1.Brake(); Car1.StopEngine("Phut phut"); Console.WriteLine("-------------------------------------"); Console.WriteLine("\nTesting polymorphism"); Vehicle w = new Vehicle(); w.Drive(); w = Car1; w.Drive(); w = myPlane; w.Drive(); Console.WriteLine("-------------------------------------"); Console.WriteLine("Journey by motorcycle"); Motorcycle mc = new Motorcycle(); mc.StartEngine("Voom Voom"); mc.Accelerate(); mc.Drive(); mc.Brake(); mc.StopEngine("Klunk Klunk"); }
static void doWork() { Console.WriteLine("This is Vehicles Lab"); Console.WriteLine("======================================================================================"); Console.WriteLine("Journey by airplane"); Airplane myPlane = new Airplane(); myPlane.StartEngine("contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("======================================================================================"); Console.WriteLine("Journey by car:"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine("======================================================================================"); Console.WriteLine("Testing polymorphism"); Vehicle v = myCar; v.Drive(); v = myPlane; v.Drive(); Console.WriteLine("======================================================================================"); SpaceShip challenger = new SpaceShip(); challenger.StartEngine("boooom"); challenger.TakeOff(); challenger.Drive(); challenger.Fire(); challenger.Land(); challenger.StopEngine("ssssssssssss"); }
static void doWork() { Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine("\nJourney by car:"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); }
static void doWork() { Console.WriteLine("Journey by airplane:"); Airplane myPlane = new Airplane(); myPlane.StartEngine("Contact"); myPlane.TakeOff(); myPlane.Drive(); myPlane.Land(); myPlane.StopEngine("Whirr"); Console.WriteLine(); Console.WriteLine("Journey by car:"); Car myCar = new Car(); myCar.StartEngine("Brm brm"); myCar.Accelerate(); myCar.Drive(); myCar.Brake(); myCar.StopEngine("Phut phut"); Console.WriteLine(); Console.WriteLine("Journey by ship"); Boat myBoat = new Boat(); myBoat.StartEngine("Sirens"); myBoat.setSail(); myBoat.Drive(); myBoat.anchor(); myBoat.StartEngine("whoosh"); Console.WriteLine("\nTesting polymorphism"); Vehicles v = myCar; v.Drive(); v = myPlane; v.Drive(); v = myBoat; v.Drive(); }