Gestion du stub

pull/18/head
Leana BESSON 2 years ago
parent e42162ecd1
commit 5dae25eaa8

@ -6,9 +6,7 @@ using System.Runtime.InteropServices;
namespace MyProject;
class Program
{
public static Especetheque Especetheque { get; } = new Especetheque();
public static Zootheque Zootheque { get; set; } = new Zootheque();
static public Theque Theque { get; set; } = new ();
static void Main(string[] args)
{
MenusPrincipal();
@ -61,11 +59,11 @@ class Program
{
case 1:
Console.Clear();
Especetheque.AfficherListeEspece();
Theque.Especetheque.AfficherListeEspece();
break;
case 2:
Console.Clear();
Especetheque.SelectionnerEspece();
Theque.Especetheque.SelectionnerEspece();
break;
case 9:
Console.Clear();
@ -94,14 +92,14 @@ class Program
{
case 1:
Console.Clear();
Zootheque.AfficherListeAnimaux();
Theque.Zootheque.AfficherListeAnimaux();
break;
case 2:
Console.Clear();
Zootheque.AjouterAnimal(Especetheque);
Theque.Zootheque.AjouterAnimal(Theque.Especetheque);
break;
case 3:
Zootheque.SelectionnerAnimal(Especetheque);
Theque.Zootheque.SelectionnerAnimal(Theque.Especetheque);
break;
case 9:
Console.Clear();

@ -18,9 +18,8 @@ namespace Model
public Espece Espece { get; set; }
public Race? Race { get; set; }
public Animal(Espece espece, string nom, string dateNaissance = "", string sexe = "", string dateAdpotion = "", float? taille = null, float? poids = null, string alimentation = "", Race? race = null)
public Animal(string nom, string dateNaissance = "", string sexe = "", string dateAdpotion = "", float? taille = null, float? poids = null, string alimentation = "", Race? race = null)
{
Espece = espece;
Nom = nom;
DateNaissance = dateNaissance;
Sexe = sexe;

@ -10,16 +10,16 @@ namespace Model
{
public class Especetheque
{
public ReadOnlyCollection<Espece> ListeEspeces { get; private set; }
private readonly List<Espece> listeEspeces = new List<Espece>();
//public ReadOnlyCollection<Espece> ListeEspeces { get; private set; }
//private readonly List<Espece> listeEspeces = new List<Espece>();
public List<Espece> ListeEspeces { get; set; } = Stub.LoadEspecetheque();
public Especetheque()
{
ListeEspeces = new ReadOnlyCollection<Espece>(listeEspeces);
LoadEspecetheque();
//ListeEspeces = new ReadOnlyCollection<Espece>(listeEspeces);
}
private void LoadEspecetheque()
/*private void LoadEspecetheque()
{
HashSet<Race> Races = new HashSet<Race>();
Races.Add(new("Abyssin"));
@ -29,7 +29,7 @@ namespace Model
listeEspeces.Add(new("Chat", "Felis catus", "chat.jpg", "15 à 20 ans", "15 à 20 kg", "10 à 15 cm", Races, "Les chats ont un comportement très solitaire", "Les chats ont une bonne santé", "Les chats s'éduque assez facilement", "Il faut changé leur caisse mais il se nettoie seul, sauf les chatons", "Vétérinaire, alimentation adapté, jouet", "Un conseil"));
listeEspeces.Add(new("Hamster", "Cricetinae"));
listeEspeces.Add(new("Lapin", "Oryctolagus cuniculus"));
}
}*/
public void AfficherListeEspece()
{

@ -8,6 +8,29 @@ namespace Model
{
public class Stub
{
public static List<Espece> LoadEspecetheque()
{
List<Espece> ListeEspeces = new List<Espece>();
HashSet<Race> Races = new HashSet<Race>();
Races.Add(new("Abyssin"));
Races.Add(new("American curl"));
ListeEspeces.Add(new("Chien", "Canis lupus familiaris", "chien.jpg"));
ListeEspeces.Add(new("Chat", "Felis catus", "chat.jpg", "15 à 20 ans", "15 à 20 kg", "10 à 15 cm", Races, "Les chats ont un comportement très solitaire", "Les chats ont une bonne santé", "Les chats s'éduque assez facilement", "Il faut changé leur caisse mais il se nettoie seul, sauf les chatons", "Vétérinaire, alimentation adapté, jouet", "Un conseil"));
ListeEspeces.Add(new("Hamster", "Cricetinae"));
ListeEspeces.Add(new("Lapin", "Oryctolagus cuniculus"));
return ListeEspeces;
}
public static List<Animal> LoadZootheque()
{
List<Animal> listeAnimaux = new List<Animal>();
listeAnimaux.Add(new("Kiki"));
listeAnimaux.Add(new("PouetPouet"));
return listeAnimaux;
}
}
}

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Theque
{
public Especetheque Especetheque { get; } = new Especetheque();
public Zootheque Zootheque { get; set; } = new Zootheque();
public Theque() { }
}
}

@ -1,6 +1,8 @@
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;
@ -8,12 +10,15 @@ namespace Model
{
public class Zootheque {
public HashSet<Animal> ListeAnimaux = new HashSet<Animal>();
//public ReadOnlyCollection<Animal> ListeAnimaux { get; private set; }
//private readonly List<Animal> listeAnimaux = new List<Animal>();
public List<Animal> ListeAnimaux { get; set; } = Stub.LoadZootheque();
public Zootheque()
{
//ListeAnimaux = new ReadOnlyCollection<Animal>(listeAnimaux);
//LoadZootheque();
}
public void AfficherListeAnimaux()
{
Console.WriteLine("VOS ANIMAUX : ");
@ -36,7 +41,7 @@ namespace Model
animal.ModifierTaille();
animal.ModifierPoids();
ListeAnimaux.Add(animal);
ListeAnimaux.Append(animal);
Console.Clear();
}
@ -74,7 +79,7 @@ namespace Model
public void SupprimerAnimal(Animal animal)
{
ListeAnimaux.Remove(animal);
//ListeAnimaux.Remove(animal);
}
}
}

@ -2,13 +2,12 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.Animaux"
Title="Animaux">
Title="Vos animaux">
<VerticalStackLayout>
<Grid RowDefinitions="Auto, *"
RowSpacing="20"
Padding="20">
<Label Text="Les espèces"
FontSize="Large"/>
<ListView ItemsSource="{Binding ListeAnimal}"
<ListView ItemsSource="{Binding ListeAnimaux}"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
@ -42,4 +41,11 @@
</ListView.ItemTemplate>
</ListView>
</Grid>
<Button Text="+"
FontSize="Large"
Background="{StaticResource Primary}"
VerticalOptions="End"
HorizontalOptions="End"
Margin="20"/>
</VerticalStackLayout>
</ContentPage>

@ -4,10 +4,10 @@ namespace Views;
public partial class Animaux : ContentPage
{
public Zootheque Zootheque { get; set; } = new Zootheque();
public Animaux()
{
InitializeComponent();
BindingContext = Zootheque;
BindingContext = (App.Current as App).Theque.Zootheque;
}
}

@ -6,15 +6,17 @@ namespace Views
{
public partial class App : Application, INotifyPropertyChanged
{
public Especetheque Especetheque { get; private set; } = new Especetheque();
public Theque Theque { get; set; } = new Theque();
public Animal AnimalSelectionner;
public Espece EspeceSelectionner;
public Race RaceSelectionner;
public App()
{
InitializeComponent();
MainPage = new AppShell();
BindingContext = Especetheque;
}
}
}

@ -16,15 +16,14 @@
Background="{StaticResource Primary}"
VerticalOptions="Start"
Grid.Column="1">
<Grid RowDefinitions="Auto, *, *, *, *"
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
ColumnDefinitions="*, *"
RowSpacing="10">
RowSpacing="8">
<Label FontAttributes="Bold"
Text="Nom Scientifique"/>
Text="Nom scientifique"/>
<Label Grid.Column="1"
HorizontalOptions="End"
Text="{Binding NomScientifique}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Espérance de vie"/>
@ -32,7 +31,6 @@
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding EsperanceVie}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Poids moyen"/>
@ -40,7 +38,6 @@
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding PoidsMoyen}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Taille moyenne"/>
@ -55,54 +52,70 @@
Margin="20">
<Label Text="Comportement"
FontSize="Large"/>
<Label Text="{Binding Comportement}"
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}"/>
Background="{StaticResource Primary}">
<Label Text="{Binding Comportement}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<Label Text="Santé"
FontSize="Large"/>
<Label Text="{Binding Sante}"
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}"/>
Background="{StaticResource Primary}">
<Label Text="{Binding Sante}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<Label Text="Education"
FontSize="Large"/>
<Label Text="{Binding Education}"
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}"/>
Background="{StaticResource Primary}">
<Label Text="{Binding Education}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<Label Text="Entretien"
FontSize="Large"/>
<Label Text="{Binding Entretien}"
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}"/>
Background="{StaticResource Primary}">
<Label Text="{Binding Entretien}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<VerticalStackLayout Margin="20">
<Label Text="Coût potentiel"
FontSize="Large"/>
<Label Text="{Binding Cout}"
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}"/>
Background="{StaticResource Primary}">
<Label Text="{Binding Cout}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<VerticalStackLayout Margin="20">
<Label Text="Conseils"
FontSize="Large"/>
<Label Text="{Binding Conseil}"
FontSize="Large"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}"/>
Background="{StaticResource Primary}">
<Label Text="{Binding Conseil}"/>
</Border>
</VerticalStackLayout>
<Grid RowDefinitions="Auto, *"
@ -123,24 +136,22 @@
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
RowDefinitions="3*"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
HeightRequest="60"
WidthRequest="60"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
BorderColor="{StaticResource Primary}">
<Image Source="{Binding Image}"/>
</Frame>
<VerticalStackLayout Grid.Column="1">
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
FontSize="Large"/>
<Label Text="{Binding NomScientifique}"
Grid.Column="1"
Grid.Row="1"
FontSize="15"/>
FontSize="12"/>
</VerticalStackLayout>
</Grid>
</Border>
</Grid>

@ -19,24 +19,22 @@
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
RowDefinitions="3*"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
HeightRequest="60"
WidthRequest="60"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
BorderColor="{StaticResource Primary}">
<Image Source="{Binding Image}"/>
</Frame>
<VerticalStackLayout Grid.Column="1">
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
FontSize="Large"/>
<Label Text="{Binding NomScientifique}"
Grid.Column="1"
Grid.Row="1"
FontSize="15"/>
FontSize="12"/>
</VerticalStackLayout>
</Grid>
</Border>
</Grid>

@ -9,12 +9,12 @@ public partial class Especes : ContentPage
public Especes()
{
InitializeComponent();
BindingContext = (App.Current as App).Especetheque;
BindingContext = (App.Current as App).Theque.Especetheque;
}
public async void OnClick(object sender, SelectedItemChangedEventArgs e)
public void OnClick(object sender, SelectedItemChangedEventArgs e)
{
(App.Current as App).EspeceSelectionner = e.SelectedItem as Espece;
await Navigation.PushAsync(new DetailEspece());
Navigation.PushAsync(new DetailEspece());
}
}

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Views"
x:Class="Views.MainPage">
<Label Text="Bienvenue !"/>
</ContentPage>

Loading…
Cancel
Save