Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Juego j1 = new Juego();
            Juego j2 = new Juego("Fortnite", "Shooter", 3.3, 2018);

            j1.leer();
            j1.Mostrar();
            j2.Mostrar();
            //a) Mostrar el enesimo atributo
            j1.Mostrar(j1);
            j2.Mostrar(j2);
            //b) Verificar si es un juego del año k
            j1.Verificar(j1);
            j2.Verificar(j2);
            //c) Verificar si el juego salió el año pasado
            j1.Verificar(j1, 2020);
            j2.Verificar(j2, 2020);
            //d) Creando 3 juegos (Fornite, MarioKart, dota1)
            Juego j3 = new Juego();
            Juego j4 = new Juego();
            Juego j5 = new Juego();

            j1.Reciente(j3, j4, j5);
            //e) Sobrecargar operadores para los incisos anteriores
            j1++;
            j2++;

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void Reciente(Juego x, Juego y, Juego z)
        {
            x.leer();       x.Mostrar();
            y.leer();       y.Mostrar();
            z.leer();       z.Mostrar();
            int    max  = x.getAñoCreacion();
            string maxn = x.getNombre();

            if (y.getAñoCreacion() > max)
            {
                max  = y.getAñoCreacion();
                maxn = y.getNombre();
            }
            if (z.getAñoCreacion() > max)
            {
                max  = z.getAñoCreacion();
                maxn = z.getNombre();
            }
            Console.WriteLine("El juego más reciente es " + maxn + " que salió el año " + max);
        }