Example #1
0
        static void Main(string[] args)
        {
            Console.Title = "Ejercicio 43";
            MotoCross   m1 = new MotoCross(4, "hola", 5);
            MotoCross   m2 = new MotoCross(4, "hola", 5);
            MotoCross   m3 = new MotoCross(5, "hola2", 100);
            MotoCross   m4 = new MotoCross(6, "hola3", 20);
            MotoCross   m5 = new MotoCross(7, "hola4", 21);
            AutoF1      f1 = new AutoF1(10, "jeje");
            AutoF1      f2 = new AutoF1(11, "jeje");
            AutoF1      f3 = new AutoF1(12, "jeje");
            AutoF1      f4 = new AutoF1(13, "jeje");
            Competencia c1 = new Competencia(10, 3, Competencia.TipoCompetencia.MotoCross);

            try
            {
                if (c1 + m1)
                {
                    ;
                }

                if (c1 + m2)
                {
                    ;
                }

                if (c1 + m3)
                {
                    ;
                }

                if (c1 + m4)
                {
                    ;
                }

                if (c1 + m5)
                {
                    ;
                }

                if (c1 + f1)
                {
                    ;
                }
                if (c1 + f2)
                {
                    ;
                }

                if (c1 + f3)
                {
                    ;
                }

                if (c1 + f4)
                {
                    ;
                }
            }
            catch (CompetenciaNoDisponibleException e)
            {
                CompetenciaNoDisponibleException ee = new CompetenciaNoDisponibleException("Hotel trivago", "Clase.com", "Metodo.com", e);
                //Console.WriteLine(e.NombreClase + '\n' + e.NombreMetodo + "\n\n");
                Console.WriteLine(ee.ToString());
            }


            Console.WriteLine(c1.MostrarDatos());
            Console.WriteLine(m1.MostrarDatos());
            Console.WriteLine(f2.MostrarDatos());
            Console.WriteLine(((VehiculoDeCarrera)f2).MostrarDatos());
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.Title = "Excercise N° 43";

            #region Instances

            Competencia competencia = new Competencia(4, 6, Competencia.TipoCompetencia.F1);

            AutoF1 f1 = new AutoF1(1, "Ferrari", 500);
            AutoF1 f2 = new AutoF1(25, "Masseratti", 500);
            AutoF1 f3 = new AutoF1(7, "McLaren", 510);
            AutoF1 f5 = new AutoF1(16, "Masseratti", 88);
            AutoF1 f6 = new AutoF1(23, "Lamborghini", 115);

            MotoCross m1 = new MotoCross(1, "Honda", 160);

            #endregion

            #region Motorcycle


            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert Motorcycle in F1 Competence -----------");

            try {
                if (competencia + m1)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(m1.MostrarDatos());
                }
            } catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
            }

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

            #endregion

            #region Car

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert New Car in F1 Competence -----------");
            try {
                if (competencia + f1)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(f1.MostrarDatos());
                }
            } catch (Exception e) {
                Console.WriteLine(e.ToString());
            }

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

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert New Car in F1 Competence -----------");
            try {
                if (competencia + f2)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(f2.MostrarDatos());
                }
            } catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
            }

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

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert Repeated Car in F1 Competence -----------");
            try {
                if (competencia + f2)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(f2.MostrarDatos());
                }
            } catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
            }

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

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert New Car in F1 Competence -----------");
            try {
                if (competencia + f3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(f3.MostrarDatos());
                }
            } catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
            }
            Console.ReadKey();
            Console.Clear();

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert New Car in F1 Competence -----------");
            try {
                if (competencia + f5)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(f5.MostrarDatos());
                }
            } catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
            }

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

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Insert New Car in F1 Competence -----------");
            try {
                if (competencia + f6)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(f6.MostrarDatos());
                }
            } catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
            }

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

            #endregion

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("----------- Data of Competence -----------");
            Console.WriteLine(competencia.MostrarDatos());
            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            Competencia grandPrix = new Competencia(10, 2, Competencia.TipoCompetencia.F1);
            Competencia motoPrix  = new Competencia(15, 3, Competencia.TipoCompetencia.MotoCross);
            AutoF1      auto1     = new AutoF1(1, "fiordos");
            MotoCross   moto1     = new MotoCross(3, "honda");
            MotoCross   moto2     = new MotoCross(1, "shamaha");
            AutoF1      auto2     = new AutoF1(3, "chevrolet");
            AutoF1      auto3     = new AutoF1(2, "ford");
            AutoF1      auto4     = new AutoF1(3, "chevrolet");

            try
            {
                if (motoPrix + moto1)
                {
                    Console.WriteLine("La moto2 se agrego a la competencia motoPrix");
                }
                else
                {
                    Console.WriteLine("La moto2 NO se agrego a la competencia motoPrix");
                }
                if (motoPrix + moto2)
                {
                    Console.WriteLine("La moto2 se agrego a la competencia motoPrix");
                }
                else
                {
                    Console.WriteLine("La moto2 NO se agrego a la competencia motoPrix");
                }


                if (grandPrix + auto1)
                {
                    Console.WriteLine("El auto1 se agrego a la competencia grandPrix");
                }
                else
                {
                    Console.WriteLine("El auto1 NO se agrego a la competencia grandPrix");
                }
                if (grandPrix + moto1)
                {
                    Console.WriteLine("El moto1 se agrego a la competencia grandPrix");
                }
                else
                {
                    Console.WriteLine("El moto1 NO se agrego a la competencia grandPrix");
                }
                if (grandPrix + auto2)
                {
                    Console.WriteLine("El auto2 se agrego a la competencia grandPrix");
                }
                else
                {
                    Console.WriteLine("El auto2 NO se agrego a la competencia grandPrix");
                }

                if (grandPrix + auto3)
                {
                    Console.WriteLine("El auto3 se agrego a la competencia grandPrix");
                }
                else
                {
                    Console.WriteLine("El auto3 NO se agrego a la competencia grandPrix");
                }
                if (grandPrix + auto4)
                {
                    Console.WriteLine("El auto4 se agrego a la competencia grandPrix");
                }
                else
                {
                    Console.WriteLine("El auto4 NO se agrego a la competencia grandPrix");
                }
            }
            catch (CompetenciaNoDisponibleException e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
                Console.ForegroundColor = ConsoleColor.White;
            }
            //
            if (auto1.EnCompetencia)
            {
                Console.WriteLine("Info {0}", auto1.MostrarDatos());
            }
            if (auto2.EnCompetencia)
            {
                Console.WriteLine("Info {0}", auto2.MostrarDatos());
            }
            if (auto3.EnCompetencia)
            {
                Console.WriteLine("Info {0}", auto3.MostrarDatos());
            }
            if (auto4.EnCompetencia)
            {
                Console.WriteLine("Info {0}", auto4.MostrarDatos());
            }
            if (moto1.EnCompetencia)
            {
                Console.WriteLine("Info 1 {0}", moto1.MostrarDatos());
            }
            if (moto2.EnCompetencia)
            {
                Console.WriteLine("Info 1 {0}", moto2.MostrarDatos());
            }
            Console.ReadKey();
        }