Example #1
0
        static void Main(string[] args)
        {
            int a = 0;
            int b = 0;

            Car car1 = new Mazda(1500, 4000);
            Car car2 = new Toyota(2000, 3000);

            try
            {
                a = car1.summ();
                b = car2.summ();
                if ((a | b) > 5000)
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Too expensive");
            }
            finally
            {
                Console.WriteLine(a);
                Console.WriteLine(b);
            }
            Console.Read();
        }
Example #2
0
        static void Main(string[] args)
        {
            var mazda = new Mazda(150);

            mazda.Drive();
            SomeFunction(mazda);
            System.Console.WriteLine(mazda.Name);
        }
Example #3
0
        /* theory
         * private int mSomeMember = 3;
         * public int MyProperty { get; set; } = 10;
         *
         * public int MyPropertyExtended
         * {
         *  get => mSomeMember;
         *  set
         *  {
         *      if (value > 0)
         *          mSomeMember = value;
         *  }
         * }
         *
         * public Program()
         * {
         *  mSomeMember = 5;
         * }
         *
         * static void Main(string[] args)
         * {
         *  var program = new Program();
         *
         *  var car = new Car();
         *
         *  //car.WheelSize = 10;
         *
         *  System.Console.WriteLine(car.WheelSize);
         * }
         */
        public static void Main(string[] args)
        {
            var mazda   = new Mazda();
            var porsche = new Porsche();

            var car = new Car();

            SomeFunction(mazda);
        }
Example #4
0
        static void Prog1()
        {
            Mazda cx3 = new Mazda();

            cx3.MazdaType  = MyEnum.MazdaType.CX3;
            cx3.Color      = MyEnum.CarColor.Red;
            cx3.Door       = 5;
            cx3.SpeedLimit = 250;

            cx3.Speed = 80;
            cx3.Accelerate();
            Console.WriteLine("Now Speed = {0}", cx3.Speed);
            cx3.Accelerate();
            Console.WriteLine("Now Speed = {0}", cx3.Speed);
            cx3.Speed = 250;
            cx3.Accelerate();
            Console.WriteLine("Now Speed = {0}", cx3.Speed);
            Console.Read();
        }
Example #5
0
        public static void Execute()
        {
            BaseCar _carFerrai = new Ferrari("Enzo 2012")
            {
                precio = 15000000
            };
            BaseCar _carMazda = new Mazda("M3 2012")
            {
                precio = 10000000
            };

            BaseCar _car1 = _carFerrai.Clone();

            _car1.Modelo = "Enzo 2015";
            _car1.SetCaracteristicas(true, false);

            BaseCar _car2 = _carMazda.Clone();

            _car2.Modelo = "M6 2016";
            _car2.precio = 13000000;

            List <BaseCar> _ListCars = new List <BaseCar>();
            int            _cont     = 1;

            _ListCars.AddRange(new BaseCar[] { _car1, _carFerrai });

            foreach (BaseCar car in _ListCars)
            {
                Console.WriteLine($"********** Carro #{_cont} **********");
                Console.WriteLine($"Modelo: {car.Modelo}");
                Console.WriteLine($"Precio: {car.precio}");
                Console.WriteLine($"Es Automatico: {car._Caracteristicas.Automatico.ToString()}");
                Console.WriteLine($"Tiene GPS: {car._Caracteristicas.Gps.ToString()}");
                Console.WriteLine("");
                _cont++;
            }
        }