예제 #1
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();
        }
예제 #2
0
        static void Main(string[] args)
        {
            AutoF1 auto1 = new AutoF1("Lannister", 10);
            AutoF1 auto2 = new AutoF1("Targaryan", 60, 180);

            MotoCross moto1 = new MotoCross("Stark", 80, 5);

            VehiculoDeCarrera vehiculo = new VehiculoDeCarrera("Baratheon", 5);

            Competencia carreraAutos = new Competencia(2, 6, Competencia.TipoCompetencia.F1);
            Competencia carreraMotos = new Competencia(5, 10, Competencia.TipoCompetencia.MotoCross);

            try
            {
                if (carreraMotos + auto1)
                {
                    Console.WriteLine("Auto agregado con éxito");
                }

                //else
                //{
                //    Console.WriteLine("No se pueden AGREGAR Autos en competencias de Motos");
                //}

                if (carreraMotos + moto1)
                {
                    Console.WriteLine("Moto agregada con éxito");
                }
                else
                {
                    Console.WriteLine("No se pudo agregar");
                }

                Console.WriteLine(carreraMotos.MostrarDatos());

                if (carreraAutos + moto1)
                {
                    Console.WriteLine("Moto agregado con éxito");
                }
                else
                {
                    Console.WriteLine("No se pueden AGREGAR motos en competencias de AUTOS");
                }

                if (carreraAutos + auto1)
                {
                    Console.WriteLine("Auto agregado con éxito");
                }
                else
                {
                    Console.WriteLine("No se pudo agregar");
                }

                if (carreraAutos + auto2)
                {
                    Console.WriteLine("Auto agregado con éxito");
                }
                else
                {
                    Console.WriteLine("No se pudo agregar");
                }
            }
            catch (CompetenciaNoDisponibleException exCom)
            {
                Console.WriteLine(exCom.ToString());
            }


            Console.WriteLine(carreraAutos.MostrarDatos());

            Console.ReadKey();
        }
예제 #3
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();
        }