Exemple #1
0
        static void Main(string[] args)
        {
            Electrodomestico MyElect = new Electrodomestico(100, Color.azul, EnergyClass.C, 50);

            MyElect.PrecioFinal();
            Console.WriteLine("Price->" + MyElect.GetPrice());
            Console.WriteLine("Color->" + MyElect.GetColor());
            Console.WriteLine("Energy->" + MyElect.GetEnergyClass());
            Console.WriteLine("Weight->" + MyElect.GetWeight());

            Lavadora MyLavadora = new Lavadora(40, 100, Color.azul, EnergyClass.C, 50);

            MyLavadora.PrecioFinal();
            Console.WriteLine("\nPrice->" + MyLavadora.GetPrice());
            Console.WriteLine("Color->" + MyLavadora.GetColor());
            Console.WriteLine("Energy->" + MyLavadora.GetEnergyClass());
            Console.WriteLine("Weight->" + MyLavadora.GetWeight());
            Console.WriteLine("Charge->" + MyLavadora.GetCarga());

            Television MyTv = new Television(42, true, 100, Color.azul, EnergyClass.C, 50);

            MyTv.PrecioFinal();
            Console.WriteLine("\nPrice->" + MyTv.GetPrice());
            Console.WriteLine("Color->" + MyTv.GetColor());
            Console.WriteLine("Energy->" + MyTv.GetEnergyClass());
            Console.WriteLine("Weight->" + MyTv.GetWeight());
            Console.WriteLine("Resolution->" + MyTv.GetResolution());
            Console.WriteLine("TDT->" + MyTv.GetTdt());



            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Electrodomestico[] electrodomesticos = new Electrodomestico[10];
            electrodomesticos[0] = new Electrodomestico();
            electrodomesticos[1] = new Electrodomestico(200, 40);
            electrodomesticos[2] = new Electrodomestico(150, 'C', "Blanco", 30);
            electrodomesticos[3] = new Lavadora();
            electrodomesticos[4] = new Lavadora(300, 80);
            electrodomesticos[5] = new Lavadora(10, 250, "NEGRO", 'F', 70);
            electrodomesticos[6] = new Television();
            electrodomesticos[7] = new Television(400, 10);
            electrodomesticos[8] = new Television(45, true, 500, 'F', "RoJo", 8);
            electrodomesticos[9] = new Electrodomestico();
            decimal precioTotalElectrodomesticos = 0,
                    precioTotalLavadoras         = 0,
                    precioTotalTelevision        = 0;

            for (int i = 0; i < electrodomesticos.Length; i++)
            {
                // Console.WriteLine(electrodomesticos[i].precioFinal() + " "+electrodomesticos[i].GetType());
                decimal precio = electrodomesticos[i].precioFinal();
                if (electrodomesticos[i].GetType() == typeof(Lavadora))
                {
                    precioTotalLavadoras += precio;
                }
                else if (electrodomesticos[i].GetType() == typeof(Television))
                {
                    precioTotalTelevision += precio;
                }

                precioTotalElectrodomesticos += precio;
            }
            Console.WriteLine(precioTotalElectrodomesticos + " ELECTRODOMESTICOS");
            Console.WriteLine(precioTotalLavadoras + " LAVADORAS");
            Console.WriteLine(precioTotalTelevision + " TELEVISIONES");
        }