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(); }
public static void Main() { // Build a collection of all vehicles that fly var cessna = new Cessna(); var archer = new PiperArcher(); var airVehicles = new List <IAircraft> { cessna, archer }; // With a single `foreach`, have each vehicle Fly() foreach (var aircraft in airVehicles) { aircraft.Start(); aircraft.Fly(); aircraft.Stop(); Console.ReadLine(); } // Build a collection of all vehicles that operate on roads var motorcycle = new Motorcycle(); var ambulance = new Ambulance(); var landVehicles = new List <ILandCraft> { motorcycle, ambulance }; // With a single `foreach`, have each road vehicle Drive() foreach (var vehicle in landVehicles) { vehicle.Start(); vehicle.Drive(); vehicle.Stop(); Console.ReadLine(); } // Build a collection of all vehicles that operate on water var jetSki = new JetSki(); var ferry = new Ferry(); var waterVehicles = new List <IWaterCraft> { ferry, jetSki }; // With a single `foreach`, have each water vehicle Drive() foreach (var waterCraft in waterVehicles) { waterCraft.Start(); waterCraft.Drive(); waterCraft.Stop(); Console.ReadLine(); } }
public static void Main() { // Build a collection of all vehicles that fly Cessna plane = new Cessna(); Jet plane2 = new Jet(); List <IAirbased> airList = new List <IAirbased>(); airList.Add(plane); airList.Add(plane2); // With a single `foreach`, have each vehicle Fly() foreach (var item in airList) { item.Fly(); } // Build a collection of all vehicles that operate on roads Motorcycle bike = new Motorcycle(); Truck truck = new Truck(); List <IGroundbased> groundList = new List <IGroundbased>(); groundList.Add(bike); groundList.Add(truck); // With a single `foreach`, have each road vehicle Drive() foreach (var item in groundList) { item.Drive(); } // Build a collection of all vehicles that operate on water JetSki ski = new JetSki(); Pontoon boat = new Pontoon(); List <IWaterbased> waterList = new List <IWaterbased>(); waterList.Add(ski); waterList.Add(boat); // With a single `foreach`, have each water vehicle Drive() foreach (var item in waterList) { item.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly Cessna cess172 = new Cessna(); Cessna cessC34 = new Cessna(); Helicopter Chinook = new Helicopter(); Helicopter Iriqois = new Helicopter(); List <IFly> flying = new List <IFly>() { cess172, cessC34, Chinook, Iriqois }; // With a single `foreach`, have each vehicle Fly() foreach (IFly thing in flying) { thing.Fly(); } // Build a collection of all vehicles that operate on roads Van Odyssey = new Van(); Van Sienna = new Van(); Motorcycle Yellow = new Motorcycle(); Motorcycle Green = new Motorcycle(); List <IGround> ground = new List <IGround>() { Odyssey, Sienna, Yellow, Green }; // With a single `foreach`, have each road vehicle Drive() foreach (IGround thing in ground) { thing.Drive(); } // Build a collection of all vehicles that operate on water Houseboat Mine = new Houseboat(); Houseboat Yours = new Houseboat(); JetSki purple = new JetSki(); JetSki green = new JetSki(); List <IAquatic> swim = new List <IAquatic>() { Mine, Yours, purple, green }; // With a single `foreach`, have each water vehicle Drive() foreach (IAquatic thing in swim) { thing.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly // With a single `foreach`, have each vehicle Fly() Blimp blimp1 = new Blimp(); Cessna cessna1 = new Cessna(); List <IAirBased> thingsThatFly = new List <IAirBased>(); thingsThatFly.Add(blimp1); thingsThatFly.Add(cessna1); foreach (IAirBased thing in thingsThatFly) { thing.Fly(); } // Build a collection of all vehicles that operate on roads // With a single `foreach`, have each road vehicle Drive() Motorcycle motorcycle1 = new Motorcycle(); PickupTruck truck1 = new PickupTruck(); List <IVehicle> thingsOnRoad = new List <IVehicle>(); thingsOnRoad.Add(motorcycle1); thingsOnRoad.Add(truck1); foreach (IVehicle thing in thingsOnRoad) { thing.Drive(); } // Build a collection of all vehicles that operate on water // With a single `foreach`, have each water vehicle Drive() JetSki jet1 = new JetSki(); Pontoon pon1 = new Pontoon(); List <IVehicle> thingsOnWater = new List <IVehicle>(); thingsOnWater.Add(jet1); thingsOnWater.Add(pon1); foreach (IVehicle thing in thingsOnWater) { thing.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly HotAirBalloon balloon1 = new HotAirBalloon(); HotAirBalloon balloon2 = new HotAirBalloon(); List <IAirbased> flyingstuff = new List <IAirbased>(); flyingstuff.Add(balloon1); flyingstuff.Add(balloon2); // With a single `foreach`, have each vehicle Fly() foreach (IAirbased item in flyingstuff) { item.Fly(); } // Build a collection of all vehicles that operate on roads Motorcycle motorcycle1 = new Motorcycle(); Motorcycle motorcycle2 = new Motorcycle(); Hatchback hondafit = new Hatchback(); Cessna planecar = new Cessna(); List <IGroundbased> groundstuff = new List <IGroundbased>(); groundstuff.Add(motorcycle1); groundstuff.Add(motorcycle2); groundstuff.Add(hondafit); groundstuff.Add(planecar); // With a single `foreach`, have each road vehicle Drive() foreach (IGroundbased item in groundstuff) { item.Drive(); } // Build a collection of all vehicles that operate on water JetSki jetski1 = new JetSki(); JetSki jetski2 = new JetSki(); List <IWaterbased> waterstuff = new List <IWaterbased>(); waterstuff.Add(jetski1); waterstuff.Add(jetski2); // With a single `foreach`, have each water vehicle Drive() foreach (IWaterbased item in waterstuff) { item.Drive(); } }
public static void Main() { var motorcycle = new Motorcycle(); var tricycle = new Tricycle(); var jetski = new JetSki(); var submarine = new Submarine(); var cessna = new Cessna(); var paraglider = new Paraglider(); // Build a collection of all vehicles that fly var flyers = new List <IAirVehicle>(); flyers.Add(cessna); flyers.Add(paraglider); // With a single `foreach`, have each vehicle Fly() foreach (var plane in flyers) { plane.Fly(); } // Build a collection of all vehicles that operate on roads var drivers = new List <IGroundVehicle>(); drivers.Add(motorcycle); drivers.Add(tricycle); // With a single `foreach`, have each road vehicle Drive() foreach (var ride in drivers) { ride.Drive(); } // Build a collection of all vehicles that operate on water var swimmers = new List <IWaterVehicle>(); swimmers.Add(jetski); swimmers.Add(submarine); // With a single `foreach`, have each water vehicle Drive() foreach (var fish in swimmers) { fish.Drive(); } Console.ReadLine(); }
public static void Main() { // Build a collection of all vehicles that fly List <IAir> aircrafts = new List <IAir>(); C5 galaxy = new C5(); aircrafts.Add(galaxy); Cessna bird = new Cessna(); aircrafts.Add(bird); Boieng747 southwest = new Boieng747(); aircrafts.Add(southwest); // With a single `foreach`, have each vehicle Fly() foreach (var air in aircrafts) { air.Fly(); } // Build a collection of all vehicles that operate on roads List <ILand> rovers = new List <ILand>(); Motorcycle motorcycle = new Motorcycle(); StationWagon leBaron = new StationWagon(); Lancer lancer = new Lancer(); rovers.Add(motorcycle); rovers.Add(leBaron); rovers.Add(lancer); // With a single `foreach`, have each road vehicle Drive() foreach (var rover in rovers) { rover.Drive(); } // Build a collection of all vehicles that operate on water List <IWater> floats = new List <IWater>(); JetSki yamaha = new JetSki(); Speedboat smuggler = new Speedboat(); Yacht money = new Yacht(); floats.Add(yamaha); floats.Add(smuggler); floats.Add(money); // With a single `foreach`, have each water vehicle Drive() foreach (var floaties in floats) { floaties.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly List <IAirVehicle> thingsThatFly = new List <IAirVehicle>(); Cessna plane = new Cessna(); Propplane pesticide = new Propplane(); thingsThatFly.Add(plane); thingsThatFly.Add(pesticide); // With a single `foreach`, have each vehicle Fly() foreach (IAirVehicle flys in thingsThatFly) { flys.Fly(); } // Build a collection of all vehicles that operate on roads List <ILandVehicle> thingsThatDrive = new List <ILandVehicle>(); Motorcycle bike = new Motorcycle(); Ferrari coolCar = new Ferrari(); thingsThatDrive.Add(bike); thingsThatDrive.Add(coolCar); // With a single `foreach`, have each road vehicle Drive() foreach (ILandVehicle ride in thingsThatDrive) { ride.Drive(); } // Build a collection of all vehicles that operate on water List <IWaterVehicle> thingsThatSwim = new List <IWaterVehicle>(); JetSki ski = new JetSki(); SpeedBoat midlifeCrisis = new SpeedBoat(); thingsThatSwim.Add(ski); thingsThatSwim.Add(midlifeCrisis); // With a single `foreach`, have each water vehicle Drive() foreach (IWaterVehicle swim in thingsThatSwim) { swim.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly Cessna newCessna = new Cessna(); Boeing newBoeing = new Boeing(); List <IAir> airVehicles = new List <IAir>(); airVehicles.Add(newCessna); airVehicles.Add(newBoeing); // With a single `foreach`, have each vehicle Fly() foreach (var vehicle in airVehicles) { vehicle.Fly(); } // Build a collection of all vehicles that operate on roads Motorcycle newCycle = new Motorcycle(); BMW newBmw = new BMW(); List <IGround> groundVehicles = new List <IGround>(); groundVehicles.Add(newCycle); groundVehicles.Add(newBmw); // With a single `foreach`, have each road vehicle Drive() foreach (var vehicle in groundVehicles) { vehicle.Drive(); } // Build a collection of all vehicles that operate on water JetSki newJetski = new JetSki(); Yacht newYacht = new Yacht(); List <IWater> waterVehicles = new List <IWater>(); waterVehicles.Add(newJetski); waterVehicles.Add(newYacht); // With a single `foreach`, have each water vehicle Drive() foreach (var vehicle in waterVehicles) { vehicle.Drive(); } }
public static void Main() { Cessna myPlane = new Cessna(); Boing747 myTransport = new Boing747(); // Build a collection of all vehicles that fly List <IAirCraft> flyingVics = new List <IAirCraft>(); flyingVics.Add(myPlane); flyingVics.Add(myTransport); // With a single `foreach`, have each vehicle Fly() foreach (var vic in flyingVics) { vic.Fly(); } Motorcycle harly = new Motorcycle(); PickupTruck f150 = new PickupTruck(); // Build a collection of all vehicles that operate on roads List <ILandCraft> roadVics = new List <ILandCraft> { harly, f150 }; // With a single `foreach`, have each road vehicle Drive() foreach (var vic in roadVics) { vic.Drive(); } Cessna privateJet = new Cessna(); Boing747 passengerJet = new Boing747(); // Build a collection of all vehicles that operate on water List <IAirCraft> airVics = new List <IAirCraft>(); airVics.Add(privateJet); airVics.Add(passengerJet); // With a single `foreach`, have each water vehicle Drive() foreach (var vic in airVics) { vic.Fly(); } }
static void Main(string[] args) { var cessna = new Cessna(); var ufo = new UFO(); var delorean = new DeLorean(); var ducati = new Ducati(); var jetski = new JetSki(); var tugboat = new Tugboat(); // Build a collection of all vehicles that fly var flyingStuff = new List <IFly> { cessna, ufo }; // With a single `foreach`, have each vehicle Fly() foreach (var vehicle in flyingStuff) { vehicle.Fly(); } // Build a collection of all vehicles that operate on roads var roadRunners = new List <IDriver> { delorean, ducati }; // With a single `foreach`, have each road vehicle Drive() foreach (var roadHog in roadRunners) { roadHog.Drive(); } // Build a collection of all vehicles that operate on water var waveracers = new List <ISwimmer> { jetski, tugboat }; // With a single `foreach`, have each water vehicle Drive() foreach (var boat in waveracers) { boat.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly CessiPoo cesiOneKenobi = new CessiPoo(); Cessna plainCesna = new Cessna(); List <IFly> flyList = new List <IFly>() { cesiOneKenobi, plainCesna }; // With a single `foreach`, have each vehicle Fly() foreach (IFly item in flyList) { item.Fly(); } // Build a collection of all vehicles that operate on roads Motorcycle CrotchRocket = new Motorcycle(); Moped SomeKindOfMoped = new Moped(); // With a single `foreach`, have each road vehicle Drive() List <ILand> landList = new List <ILand>() { CrotchRocket, SomeKindOfMoped }; foreach (ILand item in landList) { item.Drive(); } // Build a collection of all vehicles that operate on water JetSki imAwesome = new JetSki(); SailBoat superSailorMoon = new SailBoat(); List <IWater> waterList = new List <IWater>() { imAwesome, superSailorMoon }; // With a single `foreach`, have each water vehicle Drive() foreach (IWater item in waterList) { item.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly Cessna aCessna = new Cessna(); FighterJet aFighterJet = new FighterJet(); List <IFlyer> Flyers = new List <IFlyer>(); Flyers.Add(aCessna); Flyers.Add(aFighterJet); // With a single `foreach`, have each vehicle Fly() foreach (var air in Flyers) { air.Fly(); } // Build a collection of all vehicles that operate on roads GoKart aGoKart = new GoKart(); Motorcycle aMotorcycle = new Motorcycle(); List <IDriver> Drivers = new List <IDriver>(); Drivers.Add(aGoKart); Drivers.Add(aMotorcycle); // With a single `foreach`, have each road vehicle Drive() foreach (var road in Drivers) { road.Drive(); } // Build a collection of all vehicles that operate on water Oceanliner anOceanliner = new Oceanliner(); JetSki aJetSki = new JetSki(); List <IWater> Boats = new List <IWater>(); Boats.Add(anOceanliner); Boats.Add(aJetSki); // With a single `foreach`, have each water vehicle Drive() foreach (var water in Boats) { water.Drive(); } }
static void Main(string[] args) { var zero = new Zero(); var tesla = new Tesla(); var cessna = new Cessna(); var ram = new Ram(); var mazda = new Mazda(); zero.MainColor = "White"; tesla.MaximumOccupancy = 5; zero.Drive(); tesla.Drive(); cessna.Drive(); ram.Drive(); mazda.Drive(); }
public static void Main() { // Build a collection of all vehicles that fly Cessna dylan = new Cessna(); Helicopter cat = new Helicopter(); List <IFlying> flying = new List <IFlying>(); flying.Add(dylan); flying.Add(cat); // With a single `foreach`, have each vehicle Fly() foreach (var thing in flying) { thing.Fly(); } ; // Build a collection of all vehicles that operate on roads Motorcycle heidi = new Motorcycle(); Car spradlin = new Car(); List <IDriving> driving = new List <IDriving>(); driving.Add(heidi); driving.Add(spradlin); // With a single `foreach`, have each road vehicle Drive() foreach (var thing2 in driving) { thing2.Drive(); } ; // Build a collection of all vehicles that operate on water JetSki edward = new JetSki(); Yacht jerry = new Yacht(); List <IMaritime> sailing = new List <IMaritime>(); sailing.Add(edward); sailing.Add(jerry); // With a single `foreach`, have each water vehicle Drive() foreach (var thing3 in sailing) { thing3.Drive(); } ; }
public static void Main() { // Build a collection of all vehicles that fly List <IAirVehicle> airVehicle = new List <IAirVehicle>(); Helicopter something = new Helicopter(); Cessna some = new Cessna(); airVehicle.Add(something); airVehicle.Add(some); // With a single `foreach`, have each vehicle Fly() foreach (var item in airVehicle) { item.Fly(); } // Build a collection of all vehicles that operate on roads List <IGroundVehicle> groundVehicle = new List <IGroundVehicle>() { new Quadro4(), new Motorcycle() }; // With a single `foreach`, have each road vehicle Drive() foreach (var i in groundVehicle) { i.Drive(); } // Build a collection of all vehicles that operate on water List <IWaterVehicle> waterVehicle = new List <IWaterVehicle>() { new JetSki(), new Submarine() }; // With a single `foreach`, have each water vehicle Drive() foreach (var item in waterVehicle) { item.Drive(); } }
public static void Main() { // Build a collection of all vehicles that fly List <IAirVehicle> flyers = new List <IAirVehicle>(); Copter heli = new Copter(); Cessna plane = new Cessna(); flyers.Add(heli); flyers.Add(plane); // With a single `foreach`, have each vehicle Fly() foreach (var flyer in flyers) { flyer.Fly(); } // Build a collection of all vehicles that operate on roads List <ILandVehicle> grounders = new List <ILandVehicle> { new Truck(), new Motorcycle() }; // With a single `foreach`, have each road vehicle Drive() foreach (var vehicle in grounders) { vehicle.Drive(); } // Build a collection of all vehicles that operate on water List <IWaterVehicle> boats = new List <IWaterVehicle> { new JetSki(), new Freighter() }; // With a single `foreach`, have each water vehicle Drive() foreach (var boat in boats) { boat.Drive(); } }
static void Main(string[] args) { var jetski = new JetSki(); var houseboat = new Houseboat(); var a10warthog = new a10Warthog(); var cessna = new Cessna(); var motorcycle = new Motorcycle(); var batmobile = new Batmobile(); var landvehicles = new List <LandBased> { motorcycle, batmobile }; foreach (var type in landvehicles) { type.Drive(); } var airvehicles = new List <AirBased> { a10warthog, cessna }; foreach (var type in airvehicles) { type.Fly(); } var seavehicles = new List <SeaBased> { jetski, houseboat }; foreach (var type in seavehicles) { type.Drive(); } Console.ReadLine(); }
public static void Main(string[] args) { var jetski = new JetSki(); var waterCraft1 = new WaterCraft(jetski); waterCraft1.Move(); waterCraft1.Start(); waterCraft1.Stop(); Console.WriteLine("------------------------------------------------"); var submarine = new SubMarine(); var waterCraft2 = new WaterCraft(submarine); waterCraft2.Move(); waterCraft2.Start(); waterCraft2.Stop(); Console.WriteLine("------------------------------------------------"); var cessna = new Cessna(); var airCraft1 = new AirCraft(cessna); airCraft1.Move(); airCraft1.Start(); airCraft1.Stop(); Console.WriteLine("------------------------------------------------"); var airplane = new Airplane(); var airCraft2 = new AirCraft(airplane); airCraft2.Move(); airCraft2.Start(); airCraft2.Stop(); Console.WriteLine("------------------------------------------------"); var motorcycle = new Motorcycle(); var landCraft1 = new LandCraft(motorcycle); landCraft1.Move(); landCraft1.Start(); landCraft1.Stop(); Console.WriteLine("------------------------------------------------"); var bike = new Bike(); var landCraft2 = new LandCraft(bike); landCraft2.Move(); landCraft2.Start(); landCraft2.Stop(); Console.WriteLine("------------------------------------------------"); // Build a collection of all vehicles that fly // With a single `foreach`, have each vehicle Fly() var airCrafts = new List <AirCraft>() { airCraft1, airCraft2 }; foreach (var airCraft in airCrafts) { airCraft.Move(); } // Build a collection of all vehicles that operate on roads // With a single `foreach`, have each road vehicle Drive() var landCrafts = new List <LandCraft>() { landCraft1, landCraft2 }; foreach (var landCraft in landCrafts) { landCraft.Move(); } // Build a collection of all vehicles that operate on water // With a single `foreach`, have each water vehicle Drive() var waterCrafts = new List <WaterCraft>() { waterCraft1, waterCraft2 }; foreach (var waterCraft in waterCrafts) { waterCraft.Move(); } }
public static void Main() { // create some vehicles using the vehicle classes JetSki StriperJetSki = new JetSki(); Motorboat LargeMotorboat = new Motorboat(12); Motorboat FastMotorboat = new Motorboat(8, 6.1); Sailboat LumberingSailBoat = new Sailboat(); Motorcycle ZippyMotorcycle = new Motorcycle(); SportsCar LeMansSportsCar = new SportsCar(); SportUtilityVehicle Rover = new SportUtilityVehicle(); Cessna TravelingCessna = new Cessna(); Boeing747 AirFrance = new Boeing747(); HangGlider SeeingBrazil = new HangGlider(); // Build a collection of all vehicles that fly List <IVehicleAir> flyingVehicles = new List <IVehicleAir>() { TravelingCessna, AirFrance, SeeingBrazil }; // With a single `foreach`, have each vehicle Fly() foreach (IVehicleAir vehicle in flyingVehicles) { vehicle.Fly(); } // Build a collection of all vehicles that operate on roads List <IVehicleLand> landVehicles = new List <IVehicleLand>() { ZippyMotorcycle, LeMansSportsCar, Rover }; // With a single `foreach`, have each road vehicle Drive() foreach (IVehicleLand vehicle in landVehicles) { vehicle.Drive(); } // Build a collection of all vehicles that operate on water List <IWaterDrive> waterVehicles = new List <IWaterDrive>() { StriperJetSki, LumberingSailBoat, LargeMotorboat, FastMotorboat }; // With a single `foreach`, have each water vehicle Drive() foreach (IWaterDrive vehicle in waterVehicles) { vehicle.Drive(); } // check to see if my overloaded constructor functions for the Motorboat class work Console.WriteLine($"LargeMotorboat passenger capacity: {LargeMotorboat.PassengerCapacity}"); Console.WriteLine($"FastMotorboat Passenger Capacity: {FastMotorboat.PassengerCapacity} Engine Volume: {FastMotorboat.EngineVolume}"); }