예제 #1
0
        static void Main(string[] args)
        {
            bool           flag        = true;
            PokemonManager PokeManager = new PokemonManager();

            ///PokemonManager PokeManager = new PokemonManager();

            while (flag)
            {
                MostrarMenu();
                int opcionElegida = ObtenerOpcion();

                switch (opcionElegida)
                {
                case 1:
                    Console.WriteLine("Introduzca El nombre del POKEMON CAPTURADO");
                    string PokeName;
                    PokeName = Console.ReadLine();
                    TipoPoke();
                    int OpciTIPOPokemon = ObtenerOpcion();

                    if (OpciTIPOPokemon == 1 | OpciTIPOPokemon == 2 | OpciTIPOPokemon == 3)
                    {
                        Console.WriteLine("ingrese datos del pokemon registrado: 1ro Apodo,  2do Altura, 3ro Peso ");
                        string apodo  = Console.ReadLine();
                        double Altura = Convert.ToDouble(Console.ReadLine());
                        double Peso   = Convert.ToDouble(Console.ReadLine());

                        PokeManager.RegistrarPokemon(PokeName, apodo, OpciTIPOPokemon, Altura, Peso);
                    }
                    else
                    {
                        Console.WriteLine("EL TIPO EXISTE");
                        Console.ReadKey();
                    }
                    return;

                case 2:
                    var text = PokeManager.GetTodosPokemones();
                    Console.WriteLine(text);
                    return;

                case 3:
                    Console.WriteLine("El registro de pokemon a finalizado");
                    flag = false;
                    return;

                default:     //ME VALIDA LAS OPCIONES DEL switch (opcionElegida)
                    Console.WriteLine("ERROR, OTRO INTENTO");
                    break;
                }
            }//END WHILE


            //FUNCIONES
            void MostrarMenu()
            {
                Console.WriteLine("Seleccione una opcion");
                Console.WriteLine("1- Insert Pokemon");
                Console.WriteLine("2- List of Pokémon");
                Console.WriteLine("3- Exit");
            }

            int ObtenerOpcion()
            {
                //Console.WriteLine("Ingrese la opcion");
                int opcion = Convert.ToInt32(Console.ReadLine());

                return(opcion);
            }

            void TipoPoke()
            {
                Console.WriteLine("1- Pokemon tipo Agua");
                Console.WriteLine("2- Pokemon tipo fuego");
                Console.WriteLine("3- Pokemon tipo Planta");
            }

            //var pokemngr = new PokemonManager();
            //pokemngr.RegisterPokemon("pikachu", 123);
            //pokemngr.RegisterPokemon("pikachu", 1234);
            //pokemngr.RegisterPokemon("charizard", 1234);
            //var textToshow = pokemngr.GetAllPokemons();
            //Console.WriteLine(textToshow);


            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Boolean        bandera     = true;
            PokemonManager PokeManager = new PokemonManager();

            while (bandera)
            {
                Console.WriteLine("Desea ingresar un nuevo pokemon? Ingrese 0 para salir, 1 para continuar ingresando pokemones o 2 para listar todos los pokemones existentes");


                int.TryParse(Console.ReadLine(), out int option);


                switch (option)
                {
                case 0:
                    bandera = false;
                    break;


                // selecciona la opcion ingresar un pokemon
                case 1:

                    Console.WriteLine("Ingrese nombre del Pokemon");
                    String Nombre = Console.ReadLine();


                    //Pide el tipo

                    int Tipo;
                    Console.WriteLine("Seleccione 1 si el pokemon es tipo FUEGO, 2 tipo AGUA y 3 tipo PLANTA");
                    int.TryParse(Console.ReadLine(), out Tipo);

                    float num;

                    if (Tipo == 1 | Tipo == 2 || Tipo == 3)
                    {
                        //Pide los datos del pokemon

                        Console.WriteLine("Ingrese Alias del Pokemon");
                        var Alias = Console.ReadLine();

                        Console.WriteLine("Ingrese el Peso del Pokemon");
                        float.TryParse(Console.ReadLine(), out num);
                        var Peso = num;

                        Console.WriteLine("Ingrese Altura del Pokemon");
                        float.TryParse(Console.ReadLine(), out num);
                        var Altura = num;

                        // Lo agrega a la lista de pokemones del tipo ingresado y a la lista general

                        PokeManager.RegistrarPokemon(Nombre, Alias, Tipo, Altura, Peso);
                    }
                    else
                    {
                        // Si el tipo ingresado no es válido

                        Console.WriteLine("Tipo ingresado no válido ");
                    }

                    break;

                case 2:
                    // Selecciono la opcion listar, entonces llama a la funcion listar que genera un texto

                    var text = PokeManager.GetTodosPokemones();
                    Console.WriteLine(text);
                    break;

                default:

                    // Cuando no ingreso una opción válida ni un caracter inválido

                    Console.WriteLine("Opción NO válidad, vuelva a intentar");
                    break;
                }
            }

            Console.WriteLine("Gracias por usar nuestra Pokedex");
            Console.ReadLine();
        }