Esempio n. 1
0
        static void Main(string[] args)
        {
            VehicleFactory vFactory = new VehicleFactory();
            Car            c        = vFactory.GetVehicle("Corolla");

            Console.WriteLine(c.GetCarInfo());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter number of wheels for vehicle:");
            var wheelCount = Convert.ToInt32(Console.ReadLine());

            var newVehicle = VehicleFactory.GetVehicle(wheelCount);

            newVehicle.Drive();
            Console.WriteLine($"This vehicle has {newVehicle.NumOfWheels} wheels.");
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var v1 = VehicleFactory.GetVehicle(2);

            v1.Drive();

            var v2 = VehicleFactory.GetVehicle(4);

            v2.Drive();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            string input = ReadInput();

            var factory = VehicleFactory.Build(input);

            IAuto car = factory;

            car.TurnOn();
            car.TurnOff();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            IVehicle vehicle = VehicleFactory.Create(Vehicles.Mercedes);
            IAnimal  animal  = AnimalFactory.Create(Animals.Raven);

            Console.WriteLine(vehicle.Model);
            Console.WriteLine(vehicle.Price);

            animal.AnimalFamily();
            animal.AnimalSound();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("How many wheels will your vehicle have?");
            var numberOfWheels = Console.ReadLine();

            IVehicle vehicle1 = VehicleFactory.GetVehicle(numberOfWheels);

            Console.WriteLine();

            vehicle1.Drive();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("How many tires are on a vehicle");
            int tires = int.Parse(Console.ReadLine());

            //VehicleFactory factory = new VehicleFactory();
            IVehicle vehicle = VehicleFactory.GetVehicle(tires);



            vehicle.Drive();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            VehicleFactory vehicleFactory = new VehicleFactory();

            IVehicle vehicle = vehicleFactory.ApplyVeicule("car");

            vehicle.Delivery();

            vehicle = vehicleFactory.ApplyVeicule("motorbike");
            vehicle.Delivery();

            vehicle = vehicleFactory.ApplyVeicule("bike");
            vehicle.Delivery();
        }
Esempio n. 9
0
        static void Main(string[] args)

        {
            // Centralize the Car object creation at the factory and decouple it from Client
            var myCar = VehicleFactory.CreateCar();

            Console.WriteLine("CreateCar: " + myCar._modelName);

            // Use abstractions to create Vehicles
            var myVehicle = VehicleAbstractFactory.CreateVehicle("myVehicle");

            Console.WriteLine("CreateVehicle: " + myVehicle._modelName);
            Console.ReadKey();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            int  numberOfWheels;
            bool input = false;

            do
            {
                Console.WriteLine("Enter the amount of tires for the vehicle you want to create.");

                input = int.TryParse(Console.ReadLine(), out numberOfWheels);
            } while (input == false);

            var vehicle = VehicleFactory.GetVehicle(numberOfWheels);

            vehicle.Drive();
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            var      vehicleType = ValidateInput.ValidationVehicleChoice("What type of Vehicle do want to make?").ToLower();
            IVehicle mustang     = VehicleFactory.GetVehicle(vehicleType);

            mustang.Drive();

            vehicleType = ValidateInput.ValidationVehicleChoice("What type of Vehicle do want to make?");
            IVehicle goldWing = VehicleFactory.GetVehicle(vehicleType);

            goldWing.Drive();

            vehicleType = ValidateInput.ValidationVehicleChoice("What type of Vehicle do want to make?");
            IVehicle peterbilt = VehicleFactory.GetVehicle(vehicleType);

            peterbilt.Drive();
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Console.WriteLine("What type of vehicle do you want to make? Car or Motorcycle??");
            string userInput = Console.ReadLine();

            VehicleFactory factory   = new VehicleFactory();
            IVehicle       myVehicle = factory.CreateVehicle(userInput);

            myVehicle.Drive();

            Console.WriteLine("Let's make another vehicle");
            userInput = Console.ReadLine();

            IVehicle myVehicleTwo = factory.CreateVehicle(userInput);

            myVehicleTwo.Drive();
        }