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.
75 lines
2.0 KiB
75 lines
2.0 KiB
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<Animal> ListeAnimaux { get; set; } = new ObservableCollection<Animal>();
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|