public IInstrument GetInstrument(InstrumentType type)
        {
            IInstrument instrument = null;
            bool        found      = instruments.TryGetValue(type, out instrument);

            if (!found)
            {
                if (type == InstrumentType.Violin)
                {
                    instrument = new Violin();
                    instruments.Add(type, instrument);
                }
                else if (type == InstrumentType.Trumpet)
                {
                    instrument = new Trumpet();
                    instruments.Add(type, instrument);
                }
                else
                {
                    instrument = new Drum();
                    instruments.Add(type, instrument);
                }
            }
            return(instrument);
        }
示例#2
0
        static void Main(string[] args)
        {
            Carrito carritoUno = new Carrito(2);

            Guitarra g1   = new Guitarra(1, "Guitarra", "Gibson", "Les Paul", "usado", 10000);
            Violin   v1   = new Violin(2, "Violin", "Stradivarius", "pepito", "usado", 10000);
            Bajo     b1   = new Bajo(3, "Bajo", "Fender", "precision Bass", "nuevo", 10000);
            Bateria  bat1 = new Bateria(4, "Bateria", "Tama", "Sx", "nuevo", 10000);



            carritoUno += g1; //agrego productos al carrito
            carritoUno += v1;
            carritoUno += b1;
            carritoUno += bat1;


            Console.WriteLine(carritoUno.ToString());    //Pruebo el ToString
            carritoUno.GananciasSobreFacturacion(25000); // Pruebo el Metodo de Extension, para calcular la ganancia real, al que le paso los costos por parametro



            Console.WriteLine("--------------------------------------------------------");
            Console.WriteLine("--------------------------------------------------------");
            Console.WriteLine("Presione Tecla Para Continuar!!!!!\n\n");

            Console.ReadKey();
            Console.Clear();


            try //Prueba de Archivos TXT/Xml... Guardar y Leer
            {
                Console.WriteLine("Chequeo guardar y abrir archivos.");

                if (Carrito.GuardarXml(carritoUno))
                {
                    Console.WriteLine("SERIALIZACION EXITOSA!!!");
                }


                if (Carrito.Guardar(carritoUno))
                {
                    Console.WriteLine("Archivo guardado con exito!!\n\n");
                }



                Console.WriteLine("LECTURA ARCHIVO EN FORMATO TXT");
                Console.WriteLine(Carrito.Leer());
            }
            catch (ArchivosException ex)
            {
                Console.WriteLine(ex.Message);
            }


            Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("=== GREAT OPERA CONCERT ===");

            Director director = new Director(
                "Roberto", "Ajolfi",
                40, true, "Conservatorio di Milano");

            Person composer = new Person(
                "Ludwig", "Van Beethoven", 68, false);

            //OperaConcertEvent concert = new OperaConcertEvent(
            //    director,
            //    composer);

            ArrayList strumenti    = new ArrayList();
            Piano     piano        = new Piano("Steinway & Sons", Piano.PianoType.Grand);
            Flute     flute        = new Flute("Miyazawa Flutes", Flute.FluteType.SideBlow);
            Violin    firstViolin  = new Violin("Stradivari", 280);
            Violin    secondViolin = new Violin("Stentor", 30);

            strumenti.Add(piano);
            strumenti.Add(flute);
            strumenti.Add(firstViolin);
            strumenti.Add(secondViolin);

            OperaConcertEvent concert = new OperaConcertEvent(
                director,
                composer,
                strumenti);

            //concert.Instruments.Add(piano);
            //concert.Instruments.Add(flute);
            //concert.Instruments.Add(firstViolin);
            //concert.Instruments.Add(secondViolin);

            // PROVE GENERALI
            Console.WriteLine("--- PROVE GENERALI ---");
            foreach (Instrument instrument in concert.Instruments)
            {
                Console.WriteLine(instrument.ToString());
                instrument.Tune();
            }
            Console.WriteLine("--- FINE PROVE GENERALI ---");
            Console.WriteLine();

            // CONCERTONE !!
            Console.WriteLine("--- CONCERTONE ---");
            Console.WriteLine($"Opera di {concert.Composer.LastName}");
            Console.WriteLine($"--- Dirige: {concert.Director.LastName}");
            Console.WriteLine("------------------");
            foreach (Instrument instrument in concert.Instruments)
            {
                instrument.Play();
            }
            Console.WriteLine("--- FINE CONCERTONE ---");
        }
示例#4
0
        public void ChequearFacturacionTotal_OK()
        {
            Carrito  car  = new Carrito();
            Guitarra g1   = new Guitarra("fsda", "asdf", "fdf", "usado", 1000);
            Bateria  b1   = new Bateria("fsda", "asdf", "fdf", "usado", 1000);
            Violin   v1   = new Violin("aaa", "aaa", "ggg", "sfgd", 1000);
            Bateria  bat1 = new Bateria("sad", "sad", "asdaf", "sad", 1000);

            car += g1;
            car += b1;
            car += v1;
            car += bat1;

            float totalVentas = car.FacturacionTotal;

            Assert.AreEqual(4000, totalVentas);
        }
示例#5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Test 1, create Electric Guitar, Bass Guitar and Violin with default strings.");
            var guitar     = new ElectricGuitar();
            var bassGuitar = new BassGuitar();
            var violin     = new Violin();

            Console.WriteLine("Test 1 Play");
            guitar.Play();
            bassGuitar.Play();
            violin.Play();

            Console.WriteLine("Test 2, create Electric Guitar, Bass Guitar with 7 and 5 strings .");
            ElectricGuitar guitar2     = new ElectricGuitar(7);
            BassGuitar     bassGuitar2 = new BassGuitar(5);

            Console.WriteLine("Test 2 Play");
            guitar2.Play();
            bassGuitar2.Play();

            Console.ReadKey();
        }
 public IInstrument GetInstrument(InstrumentType type)
 {
     IInstrument instrument = null;
     bool found = instruments.TryGetValue(type, out instrument);
     if (!found)
     {
         if (type == InstrumentType.Violin)
         {
             instrument = new Violin();
             instruments.Add(type, instrument);
         }
         else if(type == InstrumentType.Trumpet)
         {
             instrument = new Trumpet();
             instruments.Add(type, instrument);
         }
         else
         {
             instrument = new Drum();
             instruments.Add(type, instrument);
         }
     }
     return instrument;
 }
示例#7
0
 static void Main(string[] args)
 {
     var violin = new Violin();
 }