using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices.Marshalling; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Model { public class Zootheque { public ObservableCollection ListeAnimaux { get; set; } = new ObservableCollection(); public Zootheque() { } public void AfficherListeAnimaux() { Console.WriteLine("VOS ANIMAUX : "); foreach (Animal animal in ListeAnimaux) { Console.WriteLine(animal.Nom); } } public Animal AjouterAnimal() { Animal animal = new Animal(); ListeAnimaux.Add(animal); return animal; } public Animal? RechercherAnimal(string choix) { foreach (Animal animal in ListeAnimaux) { if (animal.Nom == choix) { return animal; } } return null; } public void SelectionnerAnimal(Especetheque especetheque) { string choix = ""; while (choix != "-1") { AfficherListeAnimaux(); Console.Write("\n\tEntrer le nom de l'animal à sélectionner (-1 pour annuler) : "); choix = Console.ReadLine(); Animal animal = RechercherAnimal(choix); if (animal != null) { animal.AfficherAnimal(this, especetheque); } else Console.WriteLine("\tChoix incorrect\n"); } } public void SupprimerAnimal(Animal animal) { ListeAnimaux.Remove(animal); } } }