using System; namespace Example51 { public interface IVehicle { void Start(); void Stop(); void Accelerate(); void Decelerate(); void Turn(String direction); } public class SportsCar : IVehicle { #region IVehicle Members public void Start() { // TODO: Add SportsCar.Start implementation Console.WriteLine("Starts like a sports car"); } public void Stop() { // TODO: Add SportsCar.Stop implementation } public void Accelerate() { // TODO: Add SportsCar.Accelerate implementation } public void Decelerate() { // TODO: Add SportsCar.Decelerate implementation } public void Turn(String direction) { // TODO: Add SportsCar.Turn implementation } #endregion } public class Van : IVehicle { #region IVehicle Members public void Start() { // TODO: Add Van.Start implementation Console.WriteLine("Starts like a van"); } public void Stop() { // TODO: Add Van.Stop implementation } public void Accelerate() { // TODO: Add Van.Accelerate implementation } public void Decelerate() { // TODO: Add Van.Decelerate implementation } public void Turn(String direction) { // TODO: Add Van.Turn implementation } #endregion } /// /// Summary description for Class1. /// class Class1 { public static void Drive(IVehicle vehicle) { vehicle.Start(); } /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { // // TODO: Add code to start application here // Van miniVan = new Van(); SportsCar sportsCar = new SportsCar(); miniVan.Start(); sportsCar.Start(); Drive(miniVan); Drive(sportsCar); } } }