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.
81 lines
2.2 KiB
81 lines
2.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Model
|
|
{
|
|
public class Zootheque {
|
|
|
|
public HashSet<Animal> ListeAnimaux = new HashSet<Animal>();
|
|
|
|
public Zootheque()
|
|
{
|
|
}
|
|
|
|
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.Add(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);
|
|
}
|
|
}
|
|
}
|