You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Theque
{
public List<Espece> ListeEspeces { get; set; }
public ObservableCollection<Animal> ListeAnimaux { get; set; }
public Theque()
{
ListeEspeces = Stub.LoadEspecetheque();
ListeAnimaux = new ObservableCollection<Animal>();
}
public Animal AjouterAnimal()
{
Animal animal = new Animal();
ListeAnimaux.Add(animal);
return animal;
}
public void SupprimerAnimal(Animal animal)
{
ListeAnimaux.Remove(animal);
}
public Animal? RechercherAnimal(string choix)
{
foreach (Animal animal in ListeAnimaux)
{
if (animal.Nom == choix)
{
return animal;
}
}
return null;
}
public Espece? RechercherEspece(string choix)
{
foreach (Espece espece in ListeEspeces)
{
if (espece.Nom == choix)
{
return espece;
}
}
return null;
}
}
}