public List <Videojuego> Busqueda(Eestilo e) { List <Videojuego> listAux = new List <Videojuego>(); foreach (Videojuego v in videogames) { if (v.Estilo == e) { listAux.Add(v); } } return(listAux); }
public static Eestilo eligeEstilo() { int opcEnum = 0; bool flagEnum = false; Eestilo styleGam = Eestilo.ARCADE; do { flagEnum = true; opcEnum = -1; Console.WriteLine("Define el género eligiendo una opción del 0 al 4 incluidos"); Console.WriteLine("0-ARCADE"); Console.WriteLine("1-VIDEOAVENTURA"); Console.WriteLine("2-SHOOTEMUP"); Console.WriteLine("3-ESTRATEGIA"); Console.WriteLine("4-DEPORTIVO"); try { opcEnum = Convert.ToInt32(Console.ReadLine()); if (opcEnum > Enum.GetNames(typeof(Eestilo)).Length - 1 || opcEnum < 0) { flagEnum = false; Console.WriteLine("Valor fuera de la escala"); } else { styleGam = (Eestilo)opcEnum; } } catch (ArgumentException) { Console.WriteLine("Debes escribir un numero integral con valores entre 0 y 4 incluidos"); flagEnum = false; } catch (FormatException) { Console.WriteLine("Debes escribir un numero integral con valores entre 0 y 4 incluidos"); flagEnum = false; } catch (OverflowException) { Console.WriteLine("Debes escribir un numero integral con valores entre 0 y 4 incluidos"); flagEnum = false; } } while (!flagEnum); return(styleGam); }
public static Videojuego rellenaGame() { int anInsert = 0; string titulGame; Eestilo styleGam = 0; Console.WriteLine("Dime el titulo del juego: "); titulGame = Console.ReadLine().Trim(); bool anValid; do { anValid = true; Console.WriteLine("Dime el año"); try { anInsert = Convert.ToInt32(Console.ReadLine()); if (anInsert > 2024 || anInsert < 1958) { Console.WriteLine("Antes del 58 no existian los videojuegos y no voy a permitir anunciar juegos para sabe dios cuando"); anValid = false; } } catch (ArgumentException) { Console.WriteLine("Debes escribir un año válido"); anValid = false; } catch (FormatException) { Console.WriteLine("Debes escribir un año válido"); anValid = false; } catch (OverflowException) { Console.WriteLine("Debes escribir un año válido"); anValid = false; } } while (!anValid); styleGam = eligeEstilo(); return(new Videojuego(titulGame, anInsert, styleGam)); }
public Videojuego(string titulo, int ano, Eestilo e) { this.titulo = titulo; this.ano = ano; this.estilo = e; }