Exemple #1
0
        private static Random randomMarcas; // es unico para esta clase.

        public Auto()
        {
            this.Fabricante           = (eFabricante)(Auto.randomMarcas.Next(0, 3));
            this.DI                   = new Rueda();
            this.DD                   = new Rueda();
            this.TI                   = new Rueda();
            this.TD                   = new Rueda();
            this.KilometrosRecorridos = 0;
            this.TiempoDemorado       = 0;

            Auto.contadorDeObjetos++;
        }
Exemple #2
0
        static void Main(string[] args)
        {
            /*
             * EFabricante fabricante;
             * fabricante = EFabricante.Honda;
             *
             * Console.WriteLine(fabricante);
             *
             * fabricante = (EFabricante)1;
             * Console.WriteLine(fabricante);
             */

            Rueda otraRueda  = new Rueda(3);
            Rueda otraRueda2 = new Rueda("RuedaLoca");
            Rueda otraRueda3 = new Rueda("Firestone", 15);

            Carrera carrera = new Carrera();

            Auto nuevoAuto1 = new Auto();
            Auto nuevoAuto2 = new Auto();
            Auto nuevoAuto3 = new Auto();
            Auto nuevoAuto4 = new Auto();

            Tiempo    tiempo    = 5;
            Kilometro kilometro = 9;

            /*
             * Console.WriteLine("{0} {1} {2} {3}",
             *  nuevoAuto1.Fabricante,
             *  nuevoAuto2.Fabricante,
             *  nuevoAuto3.Fabricante,
             *  nuevoAuto4.Fabricante);
             */

            // carrera.MostrarCarrera();
            // carrera.PorTiempo(5);

            carrera.CorrerCarrera(tiempo);

            carrera.CorrerCarrera(kilometro);

            carrera.CorrerCarrera(tiempo);

            tiempo = tiempo + 10; // funciona porque esta sobrecargado el operador

            Console.WriteLine("El tiempo es: " + (int)tiempo);

            Console.ReadKey();
        }
Exemple #3
0
 public void Agregar(Kilometro kilometro)
 {
     this.KilometrosRecorridos = this.KilometrosRecorridos + kilometro;
 }
Exemple #4
0
 public void AgregarKilometros(Kilometro kilometros)
 {
     //this.kilometrosRecorridos += kilometros;
 }
        public void CorrerCarrera(Kilometro kilometro)
        {
            int  contadorKilometros;
            Auto mayor;
            Auto menor;

            for (contadorKilometros = 0; contadorKilometros < (int)kilometro; contadorKilometros++)
            {
                this.auto1.Agregar((Tiempo)random.Next(10, 100));
                this.auto2.Agregar((Tiempo)random.Next(10, 100));
                this.auto3.Agregar((Tiempo)random.Next(10, 100));
                this.auto4.Agregar((Tiempo)random.Next(10, 100));
                this.auto5.Agregar((Tiempo)random.Next(10, 100));
                this.auto6.Agregar((Tiempo)random.Next(10, 100));
            }
            menor = mayor = auto1;
            if (this.auto2.ObtenerTiempo() < menor.ObtenerTiempo())
            {
                menor = auto2;
            }
            if (this.auto2.ObtenerTiempo() > mayor.ObtenerTiempo())
            {
                mayor = auto2;
            }
            if (this.auto3.ObtenerTiempo() < menor.ObtenerTiempo())
            {
                menor = auto3;
            }
            if (this.auto3.ObtenerTiempo() > mayor.ObtenerTiempo())
            {
                mayor = auto3;
            }
            if (this.auto4.ObtenerTiempo() < menor.ObtenerTiempo())
            {
                menor = auto4;
            }
            if (this.auto4.ObtenerTiempo() > mayor.ObtenerTiempo())
            {
                mayor = auto4;
            }
            if (this.auto5.ObtenerTiempo() < menor.ObtenerTiempo())
            {
                menor = auto5;
            }
            if (this.auto5.ObtenerTiempo() > mayor.ObtenerTiempo())
            {
                mayor = auto5;
            }
            if (this.auto6.ObtenerTiempo() < menor.ObtenerTiempo())
            {
                menor = auto6;
            }
            if (this.auto6.ObtenerTiempo() > mayor.ObtenerTiempo())
            {
                mayor = auto6;
            }

            Console.WriteLine("El que más tarde fue un {0} y el tiempo fue {1}", mayor.Fabricante, mayor.ObtenerTiempo());
            Console.WriteLine("El que menos tarde fue un {0} y el tiempo fue {1}", menor.Fabricante, menor.ObtenerTiempo());

            this.auto1.VolverACero();
            this.auto2.VolverACero();
            this.auto3.VolverACero();
            this.auto4.VolverACero();
            this.auto5.VolverACero();
            this.auto6.VolverACero();
        }
        public void CorrerCarrera(Kilometro kilometro)
        {
            int  contadorKilometros;
            Auto mayor = new Auto();
            Auto menor = new Auto();

            for (contadorKilometros = 0; contadorKilometros < (int)kilometro; contadorKilometros++)
            {
                /* DEPRETICATED por colecciones
                 * this.auto1.Agregar((Tiempo)numeroRandom.Next(10, 100));
                 * this.auto2.Agregar((Tiempo)numeroRandom.Next(10, 100));
                 * this.auto3.Agregar((Tiempo)numeroRandom.Next(10, 100));
                 * this.auto4.Agregar((Tiempo)numeroRandom.Next(10, 100));
                 * this.auto5.Agregar((Tiempo)numeroRandom.Next(10, 100));
                 * this.auto6.Agregar((Tiempo)numeroRandom.Next(10, 100));
                 */

                foreach (Auto item in this.ListaDeAutos)
                {
                    item.Agregar((Tiempo)numeroRandom.Next(10, 100));
                }
            }


            for (int i = 0; i < this.ListaDeAutos.Count; i++)
            {
                if (i == 0)
                {
                    menor = mayor = this.ListaDeAutos[1];
                    continue;
                }

                if (this.ListaDeAutos[i].ObtenerTiempo() < menor.ObtenerTiempo())
                {
                    menor = this.ListaDeAutos[i];
                }
                if (this.ListaDeAutos[i].ObtenerTiempo() > mayor.ObtenerTiempo())
                {
                    mayor = this.ListaDeAutos[i];
                }
            }


            /* DEPRETICATED por colecciones
             * if (this.auto2.ObtenerTiempo() < menor.ObtenerTiempo())
             *    menor = auto2;
             * if (this.auto2.ObtenerTiempo() > mayor.ObtenerTiempo())
             *    mayor = auto2;
             * if (this.auto3.ObtenerTiempo() < menor.ObtenerTiempo())
             *    menor = auto3;
             * if (this.auto3.ObtenerTiempo() > mayor.ObtenerTiempo())
             *    mayor = auto3;
             * if (this.auto4.ObtenerTiempo() < menor.ObtenerTiempo())
             *    menor = auto4;
             * if (this.auto4.ObtenerTiempo() > mayor.ObtenerTiempo())
             *    mayor = auto4;
             * if (this.auto5.ObtenerTiempo() < menor.ObtenerTiempo())
             *    menor = auto5;
             * if (this.auto5.ObtenerTiempo() > mayor.ObtenerTiempo())
             *    mayor = auto5;
             * if (this.auto6.ObtenerTiempo() < menor.ObtenerTiempo())
             *    menor = auto6;
             * if (this.auto6.ObtenerTiempo() > mayor.ObtenerTiempo())
             *    mayor = auto6;
             */

            Console.WriteLine("El que más tarde fue un {0} y el tiempo fue {1}", mayor.Fabricante, (int)mayor.ObtenerTiempo());
            Console.WriteLine("El que menos tarde fue un {0} y el tiempo fue {1}", menor.Fabricante, (int)menor.ObtenerTiempo());


            /* DEPRETICATED por colecciones
             *   this.auto1.VolverACero();
             *   this.auto2.VolverACero();
             *   this.auto3.VolverACero();
             *   this.auto4.VolverACero();
             *   this.auto5.VolverACero();
             *   this.auto6.VolverACero();*/
            foreach (Auto item in this.ListaDeAutos)
            {
                item.VolverACero();
            }
        }