Beispiel #1
0
        public List <TipoPlanta> gellAll(string sql)
        {
            try
            {
                if (conectar())
                {
                    List <TipoPlanta> lista = new List <TipoPlanta>();

                    cmd = new MySqlCommand(sql, connection);
                    MySqlDataReader myReader = cmd.ExecuteReader();
                    while (myReader.Read())
                    {
                        TipoPlanta p = new TipoPlanta(int.Parse(myReader["idTipo"].ToString()), myReader["descripcion"].ToString(), myReader["tipo"].ToString());
                        lista.Add(p);
                    }

                    return(lista);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
            finally
            {
                desConectar();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            IGolpe megaPunch    = new MegaPunch();
            IGolpe flameThrower = new FlameThrower();
            IGolpe bubbleBeam   = new BubbleBeam();
            IGolpe scratch      = new Scratch();
            IGolpe leechSeed    = new LeechSeed();

            Pokemon charmander = new TipoFogo("Charmander", 5);
            Pokemon bulbasaur  = new TipoPlanta("Bulbasaur", 5);
            Pokemon squirtle   = new TipoAgua("Squirtle", 5);
            Pokemon pikachu    = new TipoEletrico("Pikachu", 5);
            Pokemon meowth     = new TipoNormal("Meowth", 5);


            List <Pokemon> especies = new List <Pokemon>()
            {
                charmander, bulbasaur, squirtle, pikachu, meowth
            };
            List <IGolpe> golpes = new List <IGolpe>()
            {
                megaPunch, flameThrower, bubbleBeam, scratch, leechSeed
            };

            foreach (Pokemon pokemon in especies)
            {
                foreach (IGolpe golpe in golpes)
                {
                    pokemon._golpe = golpe;
                    Console.WriteLine("{0} no nível {1} utilizando {2} causa dano de {3}HP",
                                      pokemon._especie, pokemon._nivel, pokemon._golpe._nomeGolpe, pokemon.Ataque());
                }
            }
        }
        public IActionResult Create(TipoPlanta tipo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tipo);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tipo));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Nombre")] TipoPlanta tipo)
        {
            if (id != tipo.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tipo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(NotFound());
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tipo));
        }