Пример #1
0
        public Televisor RegistrarTelevisor(string nombre)
        {
            var televisor = new Televisor(nombre);

            Televisores[nombre] = televisor;
            return(televisor);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Deposito   miDeposito = 7;
            Fabricante f1         = new Fabricante("Samsung", EPais.Corea);
            Fabricante f2         = new Fabricante("Huawei", EPais.China);

            Televisor t1 = new Televisor("LED 4K", "Philips", EPais.Holanda, ETipo.Led);
            Televisor t2 = new Televisor("Plasma 2000", "Noblex", EPais.Argentina, ETipo.Plasma);
            Televisor t3 = new Televisor("LED 4K", "Philips", EPais.Holanda, ETipo.Tubo);
            Televisor t4 = new Televisor("LED 4K", "Philips", EPais.Holanda, ETipo.Led);
            Celular   c1 = new Celular("A6", f1, EGama.Media);
            Celular   c2 = new Celular("A20", f2, EGama.Alta);
            Celular   c3 = new Celular("A20", f2, EGama.Baja);
            Celular   c4 = new Celular("Iphone 12", new Fabricante("Apple", EPais.USA), EGama.Alta);
            Celular   c5 = new Celular("A20", f1, EGama.Alta);

            miDeposito += c1;
            //YA INGRESADO
            miDeposito += c1; // NO
            miDeposito += t1;
            miDeposito += t2;
            miDeposito += t3;// ERROR CON T1
            miDeposito += c2;
            miDeposito += c3;
            //YA INGRESADO
            miDeposito += t4;
            miDeposito += c4;
            //SIN LUGAR
            miDeposito += c5;
            Console.WriteLine(Deposito.Mostrar(miDeposito));
            Console.ReadLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Televisor T1 = new Televisor(130, "Sony", 10000, 42, "China");
            Program   P  = new Program();                             // Genero un obj Program para acceder al método estático.

            T1.MiEvento   += new MiDelegado(PruebaEvento);            // Agrego el método a la lista de métodos del Delegate.
            T1.MiEvento   += new MiDelegado(P.PruebaEventoInstancia); // Agrego el método de instancia a la lista de métodos.
            T1.MiEventoTV += new MiDelegadoTV(PruebaEventoConParametro);

            //
            //T1.MiEvento += new MiDelegado(PruebaEvento); // Agrego el método a la lista de métodos del Delegate.
            //T1.MiEvento += new MiDelegado(P.PruebaEventoInstancia); // Agrego el método de instancia a la lista de métodos.
            //T1.MiEventoTV += new MiDelegadoTV(PruebaEventoConParametro);
            ////
            //T1.MiEvento += new MiDelegado(PruebaEvento); // Agrego el método a la lista de métodos del Delegate.
            //T1.MiEvento += new MiDelegado(P.PruebaEventoInstancia); // Agrego el método de instancia a la lista de métodos.
            //T1.MiEventoTV += new MiDelegadoTV(PruebaEventoConParametro);

            T1.Insertar();



            Console.ReadKey();
            Televisor.Borrar(T1);
        }
Пример #4
0
 public Package(IPackageFactory factory)
 {
     laptop = factory.CreateLaptop();
     phone  = factory.CreatePhone();
     tv     = factory.CreateTelevisor();
     GetInfo();
 }
Пример #5
0
        public static void PruebaEventoConParametro(Televisor t, TVEventsArgs e)
        {
            string guiones = "------------------------------------------------------------";

            Console.WriteLine(guiones);
            Console.WriteLine("{0} | {1} | {2} | {3} | {4} a las {5}", t.codigo, t.marca, t.precio, t.pulgadas, t.pais, e.Fecha);
            Console.WriteLine(guiones);
        }
Пример #6
0
        static void Main(string[] args)
        {
            Televisor t = new Televisor(131, "Philips", 6000, 32, "EEUU");

            t.miEvento += new MiDelegado(Program.PruebaEvento);
            t.miEvento += new MiDelegado(new Program().PruebaEvento2);

            t.delegadoTV += new DelegadoTV(new Program().Mostrar);

            t.Insertar();

            Console.ReadKey();
        }
Пример #7
0
        static void Main(string[] args)
        {
            Laptop laptop = SimpleFactory.NewLaptop("Ideapad");

            MobilePhone phone = SimpleFactory.NewMobilePhone("Galaxy");

            Televisor televisor = SimpleFactory.NewTelevisor("LG");

            Console.WriteLine(laptop.GetBrand());
            Console.WriteLine(phone.GetBrand());
            Console.WriteLine(televisor.GetBrand());

            Console.ReadKey();
        }
Пример #8
0
        static void Main(string[] args)
        {
            RegistroReparaciones reparaciones = RegistroReparaciones.RecuperaXml();
            var r           = new Radio(10, "sony", "am");
            var tele        = new Televisor(1234, "LG", 52);
            var reparacion1 = Reparacion.Crea(1.5, tele.precioHora, tele.numSerie);

            reparaciones.Add(reparacion1);
            Console.WriteLine(r);
            Console.WriteLine(tele);
            Console.WriteLine(reparacion1);
            Console.WriteLine(reparacion1.calcularPrecio(100));
            reparaciones.GuardaXml();
        }
Пример #9
0
        public static void EscolhaTelevisor(string nomeProduto, double valorProduto, string cor, double voltagem)
        {
            var televisor = new Televisor(nomeProduto, valorProduto, cor, voltagem);

            televisor.Oferta();

            listaTelevisor.Add(televisor);

            foreach (var item in listaTelevisor)
            {
                Console.WriteLine($"Parabens! Graças a nossa oferta você esta aquirindo um {item.NomeProduto} de R$6000 por R${item.ValorProduto} de cor {item.Cor} e voltagem {item.Voltagem}v ");
            }
            Comprar();
        }
Пример #10
0
        static void Main(string[] args)
        {
            Program   program    = new Program();
            Televisor televisor1 = new Televisor(3472, "Bangho", 15475, 32, "Argentina");

            televisor1.MiEvento += new MiDelegado(PruebaEvento);
            televisor1.MiEvento += new MiDelegado(program.PruebaEvento2);
            televisor1.MiEvento += new MiDelegado(PruebaEvento);
            televisor1.MiEvento += new MiDelegado(program.PruebaEvento2);
            televisor1.MiEvento += new MiDelegado(PruebaEvento);
            televisor1.MiEvento += new MiDelegado(program.PruebaEvento2);
            televisor1.MiEvento += new MiDelegado(PruebaEvento);
            televisor1.MiEvento += new MiDelegado(program.PruebaEvento2);
            televisor1.EventoTV += new DelegadoTV(Program.MuestroTVAgregado);
            televisor1.Insertar();
            Console.ReadKey();
        }
Пример #11
0
        static void Main(string[] args)
        {
            Televisor miTele = new Televisor(15, "Phonic", 222, 42, "Argentina");

            //siempre ejecuta todos los metodos asociados al evento
            miTele.MiEvento += new MiDelegado(MiMetodoDelegado);
            miTele.MiEvento += new MiDelegado(new Program().MiMetodoDelegado2);
            miTele.EventoTv += new DelegadoTv(new Program().MostrarDeEvento);

            //miTele.MiEvento += new MiDelegado(MiMetodoDelegado);
            //miTele.MiEvento += new MiDelegado(new Program().MiMetodoDelegado2);
            //miTele.EventoTv += new DelegadoTv(new Program().MostrarDeEvento);

            //miTele.MiEvento += new MiDelegado(MiMetodoDelegado);
            //miTele.MiEvento += new MiDelegado(new Program().MiMetodoDelegado2);
            //miTele.EventoTv += new DelegadoTv(new Program().MostrarDeEvento);

            miTele.Insertar();
        }
Пример #12
0
        static void Main(string[] args)
        {
            Televisor tele = new Televisor(12, "hitachi", 23476, 23, "rusia");
            Program   pro  = new Program();

            Televisor.Borrar(tele); //lo borro porque viene cargado de la base de datos asi puedo volverlo a agregar


            //agrego metodos a  el atributo de eventos de mi objeto televisor

            tele.miEvento += new MiDelegado(Program.PruebaEvento);
            tele.miEvento += new MiDelegado(pro.PruebaEvento2);
            tele.eventoTv += new DelegadoTV(Program.MuestroTvAgregado);
            //inserto esa television en mi base de datos y a su vez lanzo el evento
            tele.Insertar();



            Console.ReadKey();
        }
Пример #13
0
 public static void MuestroTVAgregado(Televisor televisor, TVEventArgs args)
 {
     Console.WriteLine("\nID: {0}\nMarca: {1}\nPrecio: {2}\nPulgadas: {3}\nPais: {4}\nFecha: {5}", televisor.id, televisor.marca, televisor.precio, televisor.pulgadas, televisor.pais, args.Fecha);
 }
Пример #14
0
 public ComandoSintonizarCanalTelevisor(Televisor televisor, string canal)
 {
     _televisor = televisor;
     _canal     = canal;
 }
Пример #15
0
 public void MostrarDeEvento(Televisor Tv, TvEventsArg tv)
 {
     Console.WriteLine(Tv.ToString());
     Console.WriteLine(tv.Fecha);
     Console.ReadKey();
 }
Пример #16
0
 public ComandoEncenderTelevisor(Televisor televisor)
 {
     _televisor = televisor;
 }
Пример #17
0
        private Tuple <IComando, IComando, string> TraerComandosTelevisor(AccionesTelevisor accion, Televisor televisor,
                                                                          string[] args)
        {
            switch (accion)
            {
            case AccionesTelevisor.EncenderYApagar:
                return(new Tuple <IComando, IComando, string>(
                           new ComandoEncenderTelevisor(televisor),
                           new ComandoApagarTelevisor(televisor),
                           "prender-apagar"));

            case AccionesTelevisor.SintonizarCanales:
                if (args.Length < 2)
                {
                    Console.WriteLine("Faltan parametros para configurar televisor");
                    return(null);
                }
                return(new Tuple <IComando, IComando, string>(
                           new ComandoSintonizarCanalTelevisor(televisor, args[0]),
                           new ComandoSintonizarCanalTelevisor(televisor, args[1]),
                           "sintonizar"));
            }
            return(null);
        }
Пример #18
0
 public void Mostrar(Televisor televisor, TVEventsArgs tVEventsArgs)
 {
     Console.WriteLine(televisor.id + " - " + televisor.marca + " - " + (float)televisor.precio + " - " + televisor.pulgadas + " - " + televisor.pais);
     Console.WriteLine("Agregado a las: " + tVEventsArgs.Fecha);
 }
Пример #19
0
 public static void MuestroTvAgregado(Televisor tele, TVEventsArgs args)
 {
     Console.WriteLine("codigo: {0} marca: {1} precio: {2} pulgadas: {3} pais: {4}", tele.id, tele.marca, tele.precio, tele.pulgadas, tele.pais);
     Console.WriteLine("Horario {0:G}", args.Fecha);
 }
Пример #20
0
 public ComandoApagarTelevisor(Televisor televisor)
 {
     _televisor = televisor;
 }
Пример #21
0
        static void Main(string[] args)
        {
            SqlConnection conexion = new SqlConnection(Properties.Settings.Default.conexion);

            conexion.Open();

            SqlCommand comando = new SqlCommand();

            comando.CommandType = CommandType.Text;
            comando.CommandText = "SELECT * FROM dbo.Televisores";
            comando.Connection  = conexion;

            SqlDataReader reader = comando.ExecuteReader();
            //Televisor lista = new Televisor();
            //lista.televisores = new List<Televisor>();

            //while (reader.Read())
            //{
            //    //Se pueden usar numeros en vez del nombre del campo
            //    //Console.WriteLine(reader[0] + " - " + reader[1] + " - " + reader[2] + " - " + reader[3]+ " - "+reader[4]);

            //    //Primera opcion
            //    Televisor t1 = new Televisor(reader.GetInt32(0), reader.GetString(1), reader.GetDouble(2), reader.GetInt32(3), reader.GetString(4));
            //    lista.televisores.Add(t1);

            //    //Casteo
            //    //Televisor t2 = new Televisor((int)reader[0], (string)reader[1], (double)reader[2], (int)reader[3], (string)reader[4]);
            //    //lista.televisores.Add(t2);

            //    Console.WriteLine(reader["codigo"]+" - "+reader["marca"]+" - "+reader["pulgadas"]+" - "+reader["pais"]);
            //}

            XmlSerializer serializer = new XmlSerializer(typeof(List <Televisor>));
            XmlTextWriter xmlWriter  = new XmlTextWriter("televisores.xml", Encoding.UTF8);
            XmlTextReader xmlReader  = new XmlTextReader("televisores.xml");

            //..
            serializer.Serialize(xmlWriter, Televisor.TraerTodos());
            xmlWriter.Close();

            List <Televisor> televisors = (List <Televisor>)serializer.Deserialize(xmlReader);

            xmlReader.Close();

            conexion.Close();
            conexion.Open();

            reader = comando.ExecuteReader();

            DataTable dataTable = new DataTable("Televisores");

            dataTable.Load(reader);
            conexion.Close();

            //.
            dataTable.WriteXmlSchema("televisoresEsquema.xml");
            dataTable.WriteXml("televisoresDT.xml");

            DataTable dataTable2 = new DataTable();

            dataTable2.ReadXmlSchema("televisoresEsquema.xml");
            dataTable2.ReadXml("televisoresDT.xml");

            //Inserto algo
            Televisor tele = new Televisor(127, "Samsung", 16999, 50, "Corea del Sur");

            if (tele.Insertar())
            {
                Console.WriteLine("Se insertó.");
            }

            //Televisor tele2 = new Televisor(126,"Samsung",14000,52,"Argentina");

            //if (Televisor.Modificar(tele2))
            //{
            //    Console.WriteLine("Se modificó.");
            //}
            //else
            //{
            //    Console.WriteLine("No se modificó.");
            //}

            Televisor tele3 = new Televisor(124, "", 0, 0, "");
            //if (Televisor.Borrar(tele3))
            //{
            //  Console.WriteLine("Se borró.");
            //}
            //else
            //{
            //  Console.WriteLine("No se borró.");
            //}

            Televisor tele4 = Televisor.TraerUno(124);

            Console.WriteLine(tele4.Mostrar());

            conexion.Close();
            Console.ReadKey();
        }