static void Main(string[] args) { var zero = new Zero(); var tesla = new Tesla(); var cessna = new Cessna(); var ram = new Ram(); zero.MaximumOccupancy = 5; tesla.MaximumOccupancy = 5; cessna.MaximumOccupancy = 20; ram.MaximumOccupancy = 2; zero.MainColor = "black"; tesla.MainColor = "white"; cessna.MainColor = "red"; ram.MainColor = "blue"; zero.Drive(); tesla.Drive(); cessna.Drive(); ram.Drive(); zero.Turn(); tesla.Turn(); cessna.Turn(); ram.Turn(); zero.Stop(); tesla.Stop(); cessna.Stop(); ram.Stop(); }
static void Main(string[] args) { ICar seat = new Seat("Leon", "Grey"); ICar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat.ToString()); seat.Start(); seat.Stop(); Console.WriteLine(tesla.ToString()); tesla.Start(); tesla.Stop(); }
static void Main(string[] args) { var gasVehicle = new Toyota(); gasVehicle.Start(0); // needs to implement the Start method in Toyota Class gasVehicle.Speed(70, 1); // needs to implement the Speed method in Toyota Class gasVehicle.Stop(); // needs to implement the Stop methos in Toyota Class var electricalVehicle = new Tesla(true); electricalVehicle.Start(1); // uses over ridden method in Testa Class electricalVehicle.Speed(90, 1); // internal method electricalVehicle.Stop(); //code reuse from the Vehicle abstract class var virtulaVehicle = new Vehicle(true); // will not work as this a abstract class }