using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Runtime.InteropServices.Marshalling; using System.Text; using System.Threading.Tasks; namespace Model { public class Zootheque { //public ReadOnlyCollection ListeAnimaux { get; private set; } //private readonly List listeAnimaux = new List(); public List ListeAnimaux { get; set; } = Stub.LoadZootheque(); public Zootheque() { //ListeAnimaux = new ReadOnlyCollection(listeAnimaux); //LoadZootheque(); } public void AfficherListeAnimaux() { Console.WriteLine("VOS ANIMAUX : "); foreach (Animal animal in ListeAnimaux) { Console.WriteLine(animal.Nom); } } public void AjouterAnimal(Especetheque especetheque) { Console.WriteLine("AJOUT ANIMAL"); Animal animal = new(new(""), ""); animal.ModifierNom(); animal.ModifierEspece(especetheque); animal.ModifierRace(); animal.ModifierDateNaissance(); animal.ModifierSexe(); animal.ModifierDateAdoption(); animal.ModifierTaille(); animal.ModifierPoids(); ListeAnimaux.Append(animal); Console.Clear(); } 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); } } }