Exemplo n.º 1
0
        static void Main(string[] args)
        {
            List <ILandVehicle>  landVehicles  = new List <ILandVehicle>();
            List <IWaterVehicle> waterVehicles = new List <IWaterVehicle>();
            List <IAirVehicle>   airVehicles   = new List <IAirVehicle>();
            Car        vWBeetle = new Car();
            Motorcycle Harley   = new Motorcycle();

            landVehicles.Add(vWBeetle);
            landVehicles.Add(Harley);
            Plane      Boeing = new Plane();
            Helicopter Bell   = new Helicopter();

            airVehicles.Add(Boeing);
            airVehicles.Add(Bell);
            Boat   Bayliner = new Boat();
            Jetski SkeDoo   = new Jetski();

            waterVehicles.Add(Bayliner);
            waterVehicles.Add(SkeDoo);
            foreach (ILandVehicle vehicle in landVehicles)
            {
                vehicle.Drive();
            }
            foreach (IWaterVehicle vehicle in waterVehicles)
            {
                vehicle.Drive();
            }
            foreach (IAirVehicle vehicle in airVehicles)
            {
                vehicle.Fly();
            }
        }
Exemplo n.º 2
0
 private void EditJetski(Jetski jetski)
 {
     jetski.Name        = GetName();
     jetski.Purpose     = GetPorp();
     jetski.Seats       = GetNumSeats();
     jetski.Weight      = GetWeight();
     jetski.Waterline   = GetWLine();
     jetski.Сonsumption = GetCons();
     jetski.Type        = GetJetskiType();
 }
Exemplo n.º 3
0
 public void SetJetski(Jetski jetski)
 {
     receivedJetski = jetski;
     SetName(jetski.Name);
     SetPorp(jetski.Purpose);
     SetNumSeats(jetski.Seats);
     SetWeight(jetski.Weight);
     SetWLine(jetski.Waterline);
     SetCons(jetski.Сonsumption);
     SetJetskiType(jetski.Type);
 }
Exemplo n.º 4
0
        public static void Main()
        {
            // Build a collection of all vehicles that fly
            // With a single `foreach`, have each vehicle Fly()

            var airplane   = new KingJet(200, "White", 9);
            var helecopter = new BlackHawk(150, "Black", 5);

            List <Aircraft> aircrafts = new List <Aircraft>();

            aircrafts.Add(airplane);
            aircrafts.Add(helecopter);

            foreach (var aircraft in aircrafts)
            {
                aircraft.Fly();
            }

            // Build a collection of all vehicles that operate on roads
            // With a single `foreach`, have each road vehicle Drive()

            var audi  = new Audi("Snow White", 32, 5);
            var tesla = new Tesla("Black", 0, 5);

            List <CarBase> cars = new List <CarBase>();

            cars.Add(audi);
            cars.Add(tesla);

            foreach (var car in cars)
            {
                car.Drive();
            }

            // Build a collection of all vehicles that operate on water
            // With a single `foreach`, have each water vehicle Drive()

            var speed  = new Speedboat(100, "Blue", 7);
            var jetski = new Jetski(20, "Yellow", 2);

            List <Watercraft> boats = new List <Watercraft>();

            boats.Add(speed);
            boats.Add(jetski);

            foreach (var boat in boats)
            {
                boat.Driving();
            }
            Console.ReadLine();
        }
Exemplo n.º 5
0
 private void ButSave_Click(object sender, EventArgs e)
 {
     if (receivedJetski == null)
     {
         Jetski jetski = new Jetski();
         jetski.TypeName = TypeNames.jetski;
         EditJetski(jetski);
         FMain.AddVehicle(jetski);
     }
     else
     {
         EditJetski(receivedJetski);
     }
     Close();
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var f150      = new F150(VehicleColor.Red, 6, true);
            var prius     = new Prius(VehicleColor.White);
            var united    = new UnitedAirplane();
            var southwest = new SouthwestAirplane();
            var sailboat  = new Sailboat();
            var jetski    = new Jetski();

            var cars       = new List <Car>();
            var planes     = new List <Airplane>();
            var watercraft = new List <Watercraft>();

            cars.Add(f150);
            cars.Add(prius);
            planes.Add(united);
            planes.Add(southwest);
            watercraft.Add(sailboat);
            watercraft.Add(jetski);

            foreach (Car car in cars)
            {
                car.Drive();
            }

            foreach (Airplane plane in planes)
            {
                plane.Fly();
            }

            foreach (Watercraft oneWatercraft in watercraft)
            {
                oneWatercraft.Drive();
            }


            f150.Tailgate();
            sailboat.Refuel();
        }