static void Main(string[] args) { Caballo caballo = new Caballo("Trueno"); caballo.getNombre(); Hombre hombre = new Hombre("Juan"); hombre.getNombre(); Perros perro = new Perros("Sultan"); perro.getNombre(); Chinpance chinpance = new Chinpance("Loquillo"); //polimorfismo Console.WriteLine("Polimorfimos"); Mamiferos[] varios = new Mamiferos[3]; varios[0] = hombre; varios[1] = chinpance; varios[2] = perro; for (int i = 0; i < varios.Length; i++) { varios[i].Pensar(); } Console.ReadLine(); }
/// <summary> /// Begin a Cuarenta Match, clearing everything, shuffleing the deck and dealing the first hand. /// </summary> /// <param name="numeroDeJugadores">Number of players in the match</param> /// <param name="thisPlayer">Which player is this</param> /// <param name="dataPlayer">Which player is dealing</param> public void IniciarPartida(int numeroDeJugadores, int thisPlayer, int dataPlayer) { if (numeroDeJugadores != 2 && numeroDeJugadores != 4) { throw new ArgumentOutOfRangeException(); } //Clear the Perros (point cards) Perros.NaipesEnGrupo.Clear(); //Creat a set of Perros foreach (CardPalo palo in Enum.GetValues(typeof(CardPalo))) { foreach (CardRank rank in Enum.GetValues(typeof(CardRank))) { if (rank > CardRank.Siete && rank < CardRank.Jota) { Perros.AnadirArriba(new Naipe(rank, palo)); Perros.NaipesEnGrupo[Perros.NaipesEnGrupo.Count - 1].FaceUp = false; Perros.NaipesEnGrupo[Perros.NaipesEnGrupo.Count - 1].OnGame = false; } } } Perros.Barajar(); IniciarNuevaData(numeroDeJugadores, thisPlayer, dataPlayer); }
public async Task <ActionResult> DeleteConfirmed(int id) { Perros perros = await db.Perros.FindAsync(id); db.Perros.Remove(perros); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { Perros perros = await Task.Run(() => _perrosRepository.GetById(id)); _perrosRepository.Delete(id); await Task.Run(() => _perrosRepository.Save()); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Nombre,Chip,FechaNacimiento,CodRazaId,IdJaula")] Perros perros) { if (ModelState.IsValid) { db.Entry(perros).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.IdJaula = new SelectList(db.Jaulas, "Id", "NombreJaula", perros.IdJaula); ViewBag.CodRazaId = new SelectList(db.Razas, "Id", "Nombre", perros.CodRazaId); return(View(perros)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Nombre,Chip,FechaNacimiento,CodRazaId,IdJaula")] Perros perros) { if (ModelState.IsValid) { repositorio.Update(perros); await repositorio.Save(); return(RedirectToAction("Index")); } ViewBag.IdJaula = new SelectList(await repositorio.ListaJaulas(), "Id", "NombreJaula", perros.IdJaula); ViewBag.CodRazaId = new SelectList(await repositorio.ListaRazas(), "Id", "Nombre", perros.CodRazaId); return(View(perros)); }
// GET: Perros/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Perros perros = await db.Perros.FindAsync(id); if (perros == null) { return(HttpNotFound()); } return(View(perros)); }
// GET: Perros/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Perros perros = await repositorio.GetById(id); if (perros == null) { return(HttpNotFound()); } return(View(perros)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Nombre,Chip,FechaNacimiento,CodRazaId,IdJaula")] Perros perros) { if (ModelState.IsValid) { _perrosRepository.Insert(perros); await Task.Run(() => _perrosRepository.Save()); return(RedirectToAction("Index")); } ViewBag.IdJaula = new SelectList(_jaulasRepository.GetAll(), "Id", "NombreJaula", perros.IdJaula); ViewBag.CodRazaId = new SelectList(_razasRepository.GetAll(), "Id", "Nombre", perros.CodRazaId); return(View(perros)); }
// GET: Perros/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Perros perros = await Task.Run(() => _perrosRepository.GetById(id)); if (perros == null) { return(HttpNotFound()); } return(View(perros)); }
// GET: Perros/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Perros perros = await db.Perros.FindAsync(id); if (perros == null) { return(HttpNotFound()); } ViewBag.IdJaula = new SelectList(db.Jaulas, "Id", "NombreJaula", perros.IdJaula); ViewBag.CodRazaId = new SelectList(db.Razas, "Id", "Nombre", perros.CodRazaId); return(View(perros)); }
static void Main(string[] args) { Caballo caballo = new Caballo("Trueno"); caballo.getNombre(); Hombre hombre = new Hombre("Juan"); hombre.getNombre(); Perros perro = new Perros("Sultan"); perro.getNombre(); Console.ReadLine(); }
// GET: Perros/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Perros perros = await Task.Run(() => _perrosRepository.GetById(id)); if (perros == null) { return(HttpNotFound()); } ViewBag.IdJaula = new SelectList(_jaulasRepository.GetAll(), "Id", "NombreJaula", perros.IdJaula); ViewBag.CodRazaId = new SelectList(_razasRepository.GetAll(), "Id", "Nombre", perros.CodRazaId); return(View(perros)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Nombre,Chip,FechaNacimiento,RazaId,JaulaId")] Perros perros) { if (ModelState.IsValid) { try { await _repository.Update(perros).ConfigureAwait(false); } catch (DataException dex) { throw new PerrosException("Error al editar un perro.", dex); } return(RedirectToAction("Index")); } ViewBag.JaulaId = new SelectList(_repository.GetContext().Jaulas, "Id", "NombreJaula", perros.JaulaId); ViewBag.RazaId = new SelectList(_repository.GetContext().Razas, "Id", "Nombre", perros.RazaId); return(View(perros)); }
private void btnPruebaClases_Click(object sender, EventArgs e) { Animal a1 = new Perros(Perros.Razas.Galgo, 60); carrera += a1; Perros a2 = new Perros(Perros.Razas.Galgo, 60); carrera += a2; Humano a3 = new Humano("Juan", "Gomez", 20); carrera += a3; Caballo a4 = new Caballo("Veloz", 70); carrera += a4; Caballo a5 = new Caballo("Match 5", 75); carrera += a5; Animal a6 = new Humano("Pedro", "Martínez", 40); carrera += a6; Perros a7 = new Perros(Perros.Razas.OvejeroAleman, 50); carrera += a7; }
static void Main(string[] args) { Caballo caballo = new Caballo("Trueno"); caballo.getNombre(); Hombre hombre = new Hombre("Juan"); hombre.getNombre(); Perros perro = new Perros("Sultan"); perro.getNombre(); //principio de sustitucion Mamiferos m = new Perros("sss"); m.TomanLeche(); Mamiferos ma = new Mamiferos("Relampago"); Caballo ca = new Caballo("Terciepelo"); ma = ca; ma.getNombre(); Object miCaballo = new Caballo("Alazan"); Mamiferos[] mamif = new Mamiferos[3]; mamif[0] = caballo; mamif[1] = perro; mamif[2] = hombre; //mamif[1].getNombre(); Console.ReadLine(); }
static void Main(string[] args) { //VER ESTE EJEMPLO SIN HACER LA CLASE ANIMAL ABSTRACTA // Animal a1 = new Animal(10, 80); // Console.WriteLine( a1.MostrarDatos()); //-------------HUMANO------------------ Console.WriteLine("HUMANOS \r\n"); Humano h1 = new Humano("Lucas", "Villamayor", 29); Humano h2 = new Humano("Jorge", "Alcina", 70); Console.WriteLine(h1.MostrarHumano()); Console.WriteLine(h2.MostrarHumano()); Console.WriteLine(h1 == h2); Console.WriteLine(h1 != h2); Console.ReadLine(); Console.Clear(); //--------------Perros--------------- Console.WriteLine("PERROS \r\n"); Perros p1 = new Perros(Perros.Razas.Galgo, 40); Perros p2 = new Perros(20); Console.WriteLine(p1.MostrarPerro()); Console.WriteLine(p2.MostrarPerro()); Console.WriteLine(p1 == p2); Console.WriteLine(p1 != p2); Console.WriteLine(p1 == p1); //comparo dos iguales Console.ReadLine(); Console.Clear(); //--------------CABALLOS---------------- Console.WriteLine("Caballos \r\n"); Caballo c1 = new Caballo("Jorge", 50); Caballo c2 = new Caballo("Lusito", 20); Console.WriteLine(c1.MostrarCaballo()); Console.WriteLine(c2.MostrarCaballo()); Console.WriteLine(c1 == c2); Console.WriteLine(c1 != c2); Console.WriteLine(c1 == c1); //comparo dos iguales Console.ReadLine(); Console.Clear(); Carrera car1 = new Carrera(3); car1 += c1; car1 += c2; car1 += c1; //intento agregar uno igual car1 += p2; car1 += p1; //intento agregar uno de mas Console.WriteLine(car1 == c2); }
public async void Create(Perros perros) { this.repository.Add(perros); this.repository.Save(); }
static void Main(string[] args) { //Ejercicio 1 Animales caballo = new Animales("Caballo"); Perros labrador = new Perros("Pelusa"); Gatos negro = new Gatos("Bigotes"); caballo.comer(); caballo.dormir(); Console.WriteLine(); labrador.comer(); labrador.dormir(); Console.WriteLine(); negro.comer(); negro.dormir(); Console.WriteLine(); ///////////////////////////////// //Ejercicio 2 Animales Danes = new Perros("Lili"); Console.WriteLine("-------------------"); Danes.comer(); Danes.dormir(); Animales gatito = new Gatos("Grisi"); gatito.comer(); gatito.dormir(); Console.WriteLine("\n-------------------------"); ///Ejercicio 3 Animales[] animalArray = new Animales[3]; animalArray[0] = new Animales("Chispitas"); animalArray[1] = new Perros("Pet"); animalArray[2] = new Gatos("Mily"); foreach (Animales Pets in animalArray) { Pets.comer(); Pets.dormir(); Console.WriteLine(); } Console.WriteLine("\n>>-------------------------"); ///Ejercicio 4 /* * foreach(Animales a in animalArray) * { * a.comer(); * if (a.GetType().IsInstanceOfType(animalArray))///No encontre la equivalencia de instanceof * { * ((Perros)a).bark() * } * } * */ //Desafio Console.ReadLine(); }