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.
102 lines
3.3 KiB
102 lines
3.3 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("INFORMATION DE VOTRE ANIMAL");
|
|
Console.Write("Entrer le nom (appuyer sur entrer pour passer) : ");
|
|
string nom = Console.ReadLine();
|
|
Console.Write("Entrer la date de naissance (appuyer sur entrer pour passer) : ");
|
|
string dateNaissance = Console.ReadLine();
|
|
Console.Write("Entrer le nouveau sexe (appuyer sur entrer pour passer) : ");
|
|
string sexe = Console.ReadLine();
|
|
Console.Write("Entrer la date d'adoption (appuyer sur entrer pour passer) : ");
|
|
string dateAdoption = Console.ReadLine();
|
|
Console.Write("Entrer la taille (appuyer sur entrer pour passer) : ");
|
|
string taille = Console.ReadLine();
|
|
Console.Write("Entrer le poids (appuyer sur entrer pour passer) : ");
|
|
string poids = Console.ReadLine();
|
|
Console.Write("Entrer la alimentation (appuyer sur entrer pour passer) : ");
|
|
string alimentation = Console.ReadLine();
|
|
|
|
Espece? espece = null;
|
|
while (espece == null)
|
|
{
|
|
Console.Write("Entrer le nom de l'espèce : ");
|
|
string nomEspece = Console.ReadLine();
|
|
espece = especetheque.RechercherEspece(nomEspece);
|
|
if (espece == null)
|
|
{
|
|
Console.WriteLine("Espece inconnue\n");
|
|
}
|
|
}
|
|
|
|
Console.Write("Entrer le nom de la race : ");
|
|
string nomRace = Console.ReadLine();
|
|
Race race = espece.RechercherRace(nomRace);
|
|
|
|
|
|
ListeAnimaux.Add(new(espece, nom, dateNaissance, sexe, dateAdoption, taille, poids, alimentation, race));
|
|
}
|
|
|
|
public Animal? RechercherAnimal(string choix)
|
|
{
|
|
foreach (Animal animal in ListeAnimaux)
|
|
{
|
|
if (animal.Nom == choix)
|
|
{
|
|
return animal;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void SelectionnerAnimal()
|
|
{
|
|
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();
|
|
}
|
|
else Console.WriteLine("\tChoix incorrect\n");
|
|
}
|
|
}
|
|
|
|
public void SupprimerAnimal(Animal animal)
|
|
{
|
|
ListeAnimaux.Remove(animal);
|
|
}
|
|
}
|
|
}
|