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.
116 lines
3.7 KiB
116 lines
3.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace Model
|
|
{
|
|
public class Espece
|
|
{
|
|
public string Nom { get; }
|
|
public string NomScientifique { get; }
|
|
public string EsperanceVie { get; }
|
|
public string PoidsMoyen { get; }
|
|
public string TailleMoyenne { get; }
|
|
//public string Comportement { get; }
|
|
//public string Sante { get; }
|
|
//public string Education { get; }
|
|
//public string Entretien { get; }
|
|
//public string Cout { get; }
|
|
//public string Conseil { get; }
|
|
public HashSet<Race>? ListeRaces { get; } = new HashSet<Race>();
|
|
|
|
public Espece(string nom = "Inconnu", string nomScientifique = "Inconnu", string esperanceVie = "Inconnue", string poidsMoyen = "Inconnu", string tailleMoyenne = "Inconnue", HashSet<Race>? races = null)
|
|
{
|
|
Nom = nom;
|
|
NomScientifique = nomScientifique;
|
|
EsperanceVie = esperanceVie;
|
|
PoidsMoyen = poidsMoyen;
|
|
TailleMoyenne = tailleMoyenne;
|
|
ListeRaces = races;
|
|
}
|
|
|
|
internal void AffficherListeRace()
|
|
{
|
|
Console.WriteLine("\nLISTE DES RACES : ");
|
|
if (ListeRaces != null)
|
|
{
|
|
foreach (Race race in ListeRaces)
|
|
{
|
|
Console.WriteLine("\t" + race.Nom + " (" + race.NomScientifique + ")");
|
|
}
|
|
Console.WriteLine("\n");
|
|
}
|
|
else Console.WriteLine("\tAucune race connue.\n");
|
|
}
|
|
|
|
public void AfficherEspece()
|
|
{
|
|
Console.WriteLine("\n" + Nom);
|
|
Console.WriteLine("\tNom scientifique : " + NomScientifique);
|
|
Console.WriteLine("\tEspérance de vie : " + EsperanceVie);
|
|
Console.WriteLine("\tPoids moyen : " + PoidsMoyen);
|
|
Console.WriteLine("\tTaille moyenne : " + TailleMoyenne);
|
|
|
|
AffficherListeRace();
|
|
|
|
while (true)
|
|
{
|
|
Console.WriteLine("\n\t1- Sélectionner une race");
|
|
Console.WriteLine("\t9- Retour");
|
|
|
|
Console.Write("\n\tEntrer votre choix : ");
|
|
int decision = Convert.ToInt32(Console.ReadLine());
|
|
|
|
switch (decision)
|
|
{
|
|
case 1:
|
|
SelectionnerRace();
|
|
break;
|
|
case 9:
|
|
return;
|
|
default:
|
|
Console.WriteLine("\tChoix incorrect\n");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Race? RechercherRace(string choix)
|
|
{
|
|
foreach (Race race in ListeRaces)
|
|
{
|
|
if (race.Nom == choix)
|
|
{
|
|
return race;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void SelectionnerRace ()
|
|
{
|
|
string choix = "";
|
|
while (choix != "-1")
|
|
{
|
|
Console.Write("\n\tEntrer le nom de la race à sélectionner (-1 pour annuler) : ");
|
|
choix = Console.ReadLine();
|
|
|
|
if (choix != "-1")
|
|
{
|
|
Race race = RechercherRace(choix);
|
|
|
|
if (race != null)
|
|
{
|
|
race.AfficherRace();
|
|
}
|
|
else Console.WriteLine("\tChoix incorrect");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|