From 89add0ae766c330bd71d7fabecefc2f6f8544093 Mon Sep 17 00:00:00 2001 From: tofages1 Date: Thu, 8 Jun 2023 16:35:10 +0100 Subject: [PATCH] C'etais un test qui marche mdr --- ParionsCuite/Modeles/Autre.cs | 45 +++++ ParionsCuite/Modeles/Boissons.cs | 46 +++++ ParionsCuite/Modeles/Class1.cs | 7 + ParionsCuite/Modeles/Evenement.cs | 163 ++++++++++++++++++ ParionsCuite/Modeles/IPersistanceManager.cs | 13 ++ ParionsCuite/Modeles/Inviter.cs | 38 ++++ ParionsCuite/Modeles/Manageur.cs | 123 +++++++++++++ ParionsCuite/Modeles/Modeles.csproj | 13 ++ ParionsCuite/Modeles/Nourriture.cs | 46 +++++ ParionsCuite/Modeles/Parier.cs | 35 ++++ ParionsCuite/Modeles/Participation.cs | 162 +++++++++++++++++ ParionsCuite/ParionsCuite.sln | 12 ++ ParionsCuite/ParionsCuite/ParionsCuite.csproj | 11 +- .../TestParionsCuite/TestParionsCuite.csproj | 29 ++++ ParionsCuite/TestParionsCuite/UnitTest1.cs | 17 ++ ParionsCuite/TestParionsCuite/Usings.cs | 1 + 16 files changed, 759 insertions(+), 2 deletions(-) create mode 100644 ParionsCuite/Modeles/Autre.cs create mode 100644 ParionsCuite/Modeles/Boissons.cs create mode 100644 ParionsCuite/Modeles/Class1.cs create mode 100644 ParionsCuite/Modeles/Evenement.cs create mode 100644 ParionsCuite/Modeles/IPersistanceManager.cs create mode 100644 ParionsCuite/Modeles/Inviter.cs create mode 100644 ParionsCuite/Modeles/Manageur.cs create mode 100644 ParionsCuite/Modeles/Modeles.csproj create mode 100644 ParionsCuite/Modeles/Nourriture.cs create mode 100644 ParionsCuite/Modeles/Parier.cs create mode 100644 ParionsCuite/Modeles/Participation.cs create mode 100644 ParionsCuite/TestParionsCuite/TestParionsCuite.csproj create mode 100644 ParionsCuite/TestParionsCuite/UnitTest1.cs create mode 100644 ParionsCuite/TestParionsCuite/Usings.cs diff --git a/ParionsCuite/Modeles/Autre.cs b/ParionsCuite/Modeles/Autre.cs new file mode 100644 index 0000000..88025f8 --- /dev/null +++ b/ParionsCuite/Modeles/Autre.cs @@ -0,0 +1,45 @@ +using System; +using System.Runtime.Serialization; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Autre + { + [DataMember] + public string Nom { get; set; } + + [DataMember] + public int Quantite { get; set; } + + public Autre(string nom, int qu) + { + Nom = nom; + Quantite = qu; + } + + public Autre() + { + + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(obj, null)) return false; + if (ReferenceEquals(obj, this)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals(obj as Autre); + } + + public override string ToString() + { + return $"nom : {Nom} \n"; + } + + public override int GetHashCode() + { + return HashCode.Combine(Nom); + } + } +} + diff --git a/ParionsCuite/Modeles/Boissons.cs b/ParionsCuite/Modeles/Boissons.cs new file mode 100644 index 0000000..fa114e1 --- /dev/null +++ b/ParionsCuite/Modeles/Boissons.cs @@ -0,0 +1,46 @@ +using System; +using System.Runtime.Serialization; +using System.Security.Principal; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Boisson + { + [DataMember] + public string Nom { get; set; } + + [DataMember] + public int Quantite { get; set; } + + public Boisson(string nom, int qu) + { + Nom = nom; + Quantite = qu; + } + + public Boisson() + { + + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(obj, null)) return false; + if (ReferenceEquals(obj, this)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals(obj as Boisson); + } + + public override string ToString() + { + return $"nom : {Nom} \n"; + } + + public override int GetHashCode() + { + return HashCode.Combine(Nom); + } + } +} + diff --git a/ParionsCuite/Modeles/Class1.cs b/ParionsCuite/Modeles/Class1.cs new file mode 100644 index 0000000..2791ab1 --- /dev/null +++ b/ParionsCuite/Modeles/Class1.cs @@ -0,0 +1,7 @@ +namespace Modeles +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/ParionsCuite/Modeles/Evenement.cs b/ParionsCuite/Modeles/Evenement.cs new file mode 100644 index 0000000..0def1bd --- /dev/null +++ b/ParionsCuite/Modeles/Evenement.cs @@ -0,0 +1,163 @@ +using ParionsCuite; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Evenement : INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + + void OnPropertyChanged([CallerMemberName] string propertyName = null) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + /* Déclaration */ + [DataMember] + public string Nom { get; private set; } + [DataMember] + public string Date { get; private set; } + [DataMember] + public string Lieu { get; private set; } + [DataMember] + public string Heure { get; private set; } + + [DataMember] + public Participation Participation { get; private set; } + [DataMember] + public List ListInviter { get; private set; } + + public event Action PariAdd; + + [DataMember] + private ObservableCollection listParier; + + public ObservableCollection ListParier + { + get { return listParier; } + set + { + if (listParier != value) + { + listParier = value; + OnPropertyChanged(); + OnPariAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement + } + } + } + + + private void OnPariAdded(Parier parier) + { + // Logique à exécuter lorsque un événement est ajouté + Debug.WriteLine("Événement ajouté : "); + + } + + public bool Ajout_Pari(Parier pari) + { + ListParier.Add(pari); + OnPropertyChanged(nameof(Parier)); + PariAdd?.Invoke(pari); + return true; + } + /* Constructeur */ + + public Evenement(string nom, string date, string lieu, string heure) + { + Nom = nom; + Date = date; + Lieu = lieu; + Heure = heure; + ListInviter = new List(); + ListParier = new ObservableCollection(); + Participation = new Participation(); + } + public Evenement(string nom, string date, string lieu, string heure, Participation participation) + { + Nom = nom; + Date = date; + Lieu = lieu; + Heure = heure; + Participation = participation; + ListInviter = new List(); + ListParier = new ObservableCollection(); + } + + public Evenement(List inviters, List participations, List pariers) + { + + } + + /* Méthode Inviter */ + public bool Ajouter_inviter(Inviter I) + { + ListInviter.Add(I); + foreach (Inviter i in ListInviter) + { + if (i == I) + return true; + } + return false; + } + + public bool Supprimer_inviter(Inviter inviter) + { + return ListInviter.Remove(inviter); + } + + public int LenListInvite(List list) + { + int len = 0; + foreach (Inviter inviter in list) + { + len++; + } + return len; + } + + public List ReturnListInvite() + { + return ListInviter; + } + + /* Méthode Parie */ + public bool Ajouter_parie(Parier parier) + { + ListParier.Add(parier); + foreach (Parier p in ListParier) + { + if (p == parier) + return true; + } + return false; + } + + public bool Supprimer_parie(Parier p) + { + return ListParier.Remove(p); + } + + /* Setter */ + public void SetEvenement(string nom, string date, string lieu, string heure) + { + Nom = nom; + Date = date; + Lieu = lieu; + Heure = heure; + return; + } + + public override string ToString() + { + return $"Nom : {Nom} \nDate : {Date}\nLieu : {Lieu}\nHeure : {Heure} "; + } + } +} diff --git a/ParionsCuite/Modeles/IPersistanceManager.cs b/ParionsCuite/Modeles/IPersistanceManager.cs new file mode 100644 index 0000000..5e6d6a3 --- /dev/null +++ b/ParionsCuite/Modeles/IPersistanceManager.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace ParionsCuite.Modeles +{ + public interface IPersistanceManager + { + public ObservableCollection chargeDonnees(); + public void sauvegardeDonnees(ObservableCollection evenements); + } +} + diff --git a/ParionsCuite/Modeles/Inviter.cs b/ParionsCuite/Modeles/Inviter.cs new file mode 100644 index 0000000..41f8482 --- /dev/null +++ b/ParionsCuite/Modeles/Inviter.cs @@ -0,0 +1,38 @@ +using System; +using System.Runtime.Serialization; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Inviter + { + [DataMember] + public string Nom { get; set; } + [DataMember] + public string Prenom { get; set; } + + public Inviter(string nom, string prenom) + { + Nom = nom; + Prenom = prenom; + } + + public Inviter(string prenom) + { + Prenom = prenom; + } + + public Inviter() + { + + } + + public override string ToString() + { + return $"nom : {Nom}, prenom : {Prenom} \n"; + } + + + } +} + diff --git a/ParionsCuite/Modeles/Manageur.cs b/ParionsCuite/Modeles/Manageur.cs new file mode 100644 index 0000000..1be16a9 --- /dev/null +++ b/ParionsCuite/Modeles/Manageur.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace ParionsCuite.Modeles +{ + public class Manageur : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + public event Action EvenementAdded; + + private ObservableCollection evenement; + + public bool Value1; + public bool Value2; + public bool Value3; + void OnPropertyChanged([CallerMemberName] string propertyName = null) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + public ObservableCollection Evenement + { + get { return evenement; } + set + { + if (evenement != value) + { + evenement = value; + OnPropertyChanged(); + OnEvenementAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement + } + } + } + + private void OnEvenementAdded(Evenement evenement) + { + // Logique à exécuter lorsque un événement est ajouté + Debug.WriteLine("Événement ajouté : "); + + } + public List Invites { get; set; } + + public IPersistanceManager Persistance { get; set; } + + public Manageur(IPersistanceManager Pers) { + Invites = new List(); + Evenement = new ObservableCollection(); + Persistance = Pers; + } + + public Manageur() + { + Evenement = new ObservableCollection(); + Invites = new List(); + } + + public Manageur(ObservableCollection evenements) + { + Evenement = evenements; + } + + public bool Ajout_evenement(Evenement ev) + { + Evenement.Add(ev); + OnPropertyChanged(nameof(Evenement)); + EvenementAdded?.Invoke(ev); + return true; + } + + public bool Supprimer_evenement(Evenement ev) + { + return Evenement.Remove(ev); + } + + public List AddInvite(Inviter invite1) + { + Invites.Add(invite1); + return Invites; + } + + public List RemoveInviter(Inviter invite1) + { + Invites.Remove(invite1); + return Invites; + } + + public int LenListInvite(List list) + { + int len = 0; + foreach (Inviter inviter in list) + { + len++; + } + return len; + } + + public List ReturnListInvite() + { + return Invites; + } + + public void Charge_Donnee() + { + var donnees = Persistance.chargeDonnees(); + foreach (var donnee in donnees) + { + Evenement.Add(donnee); + } + + } + + public void Save_Data() + { + Persistance.sauvegardeDonnees(Evenement); + } + } +} diff --git a/ParionsCuite/Modeles/Modeles.csproj b/ParionsCuite/Modeles/Modeles.csproj new file mode 100644 index 0000000..5ba9b50 --- /dev/null +++ b/ParionsCuite/Modeles/Modeles.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + + + + + + + diff --git a/ParionsCuite/Modeles/Nourriture.cs b/ParionsCuite/Modeles/Nourriture.cs new file mode 100644 index 0000000..01ac45d --- /dev/null +++ b/ParionsCuite/Modeles/Nourriture.cs @@ -0,0 +1,46 @@ +using System; +using System.Runtime.Serialization; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Nourriture + { + [DataMember] + public string Nom { get; set; } + + [DataMember] + public int Quantite { get; set; } + + public Nourriture(string nom, int qu) + { + Nom = nom; + Quantite = qu; + } + + public Nourriture() + { + + } + + + public override bool Equals(object obj) + { + if (ReferenceEquals(obj, null)) return false; + if (ReferenceEquals(obj, this)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals(obj as Nourriture); + } + + public override string ToString() + { + return $"nom : {Nom} \n"; + } + + public override int GetHashCode() + { + return HashCode.Combine(Nom); + } + } +} + diff --git a/ParionsCuite/Modeles/Parier.cs b/ParionsCuite/Modeles/Parier.cs new file mode 100644 index 0000000..6ae0038 --- /dev/null +++ b/ParionsCuite/Modeles/Parier.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Parier + { + [DataMember] + public Inviter i1; + [DataMember] + public Inviter i2; + + public string But { get; private set; } + + public string Enjeu { get; private set; } + + public Parier(Inviter i1, Inviter i2, string but, string enjeu) + { + this.i1 = i1; + this.i2 = i2; + But = but; + Enjeu = enjeu; + } + + public override string ToString() + { + return $"joueur n°1 : {i1}, \njoueur n°2 : {i2}, \nbut : {But}, enjeux : {Enjeu}"; + } + } +} diff --git a/ParionsCuite/Modeles/Participation.cs b/ParionsCuite/Modeles/Participation.cs new file mode 100644 index 0000000..e2227fe --- /dev/null +++ b/ParionsCuite/Modeles/Participation.cs @@ -0,0 +1,162 @@ +using Microsoft; +using ParionsCuite; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace ParionsCuite.Modeles +{ + [DataContract] + public class Participation + { + [DataMember] + public List Boissons { get; private set; } + [DataMember] + public List Nourriture { get; private set; } + [DataMember] + public List Autre { get; private set; } + + public Participation(List boisson, List nourriture, List autre) + { + Boissons = boisson; + Nourriture = nourriture; + Autre = autre; + } + + public Participation() + { + Boissons = new List(); + Nourriture = new List(); + Autre = new List(); + } + + /* Boisson */ + + public bool Ajout_Boissons(Boisson boisson) + { + foreach (var obj in Boissons) + { + if (obj.Equals(boisson)) + { + if (boisson.Quantite > 0) + { + obj.Quantite = obj.Quantite + boisson.Quantite; + return true; + } + return false; + } + } + Boissons.AddRange((IEnumerable)boisson); + return true; + } + + public bool Sup_Boissons(Boisson boisson, int quantite) + { + foreach(var obj in Boissons) + { + if (obj.Equals(boisson)) + if (quantite > 0) + { + if (quantite >= boisson.Quantite) + { + Boissons.Remove(boisson); + return true; + } + + obj.Quantite = obj.Quantite + boisson.Quantite; + return true; + } + return false; + } + return false; + } + + + /* Nourriture */ + + public bool Ajout_Nourriture(Nourriture food) + { + foreach (var obj in Nourriture) + { + if (obj.Equals(food)) + { + if (food.Quantite > 0) + { + obj.Quantite = obj.Quantite + food.Quantite; + return true; + } + return false; + } + } + Nourriture.AddRange((IEnumerable)food); + return true; + } + + public bool Sup_Nourriture(Nourriture food, int quantite) + { + foreach (var obj in Boissons) + { + if (obj.Equals(food)) + if (quantite > 0) + { + if (quantite >= food.Quantite) + { + Nourriture.Remove(food); + return true; + } + + obj.Quantite = obj.Quantite + food.Quantite; + return true; + } + return false; + } + return false; + } + + /* Autre */ + + public bool Ajout_Autre(Autre autre) + { + foreach (var obj in Autre) + { + if (obj.Equals(autre)) + { + if (autre.Quantite > 0) + { + obj.Quantite = obj.Quantite + autre.Quantite; + return true; + } + return false; + } + } + Autre.AddRange((IEnumerable)autre); + return true; + } + + public bool Sup_Autre(Autre autre, int quantite) + { + foreach (var obj in Autre) + { + if (obj.Equals(autre)) + if (quantite > 0) + { + if (quantite >= autre.Quantite) + { + Autre.Remove(autre); + return true; + } + + obj.Quantite = obj.Quantite + autre.Quantite; + return true; + } + return false; + } + return false; + } + + } +} diff --git a/ParionsCuite/ParionsCuite.sln b/ParionsCuite/ParionsCuite.sln index c0d3348..a30429b 100644 --- a/ParionsCuite/ParionsCuite.sln +++ b/ParionsCuite/ParionsCuite.sln @@ -5,6 +5,10 @@ VisualStudioVersion = 17.0.31611.283 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParionsCuite", "ParionsCuite\ParionsCuite.csproj", "{695ECD3A-15DB-4B29-BC9D-E8CC87D92900}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modeles", "Modeles\Modeles.csproj", "{F96C29D3-33A7-4230-A1C7-799114865D52}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestParionsCuite", "TestParionsCuite\TestParionsCuite.csproj", "{0978D34C-3D5E-4863-B40C-55A38C6A2BBE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -17,6 +21,14 @@ Global {695ECD3A-15DB-4B29-BC9D-E8CC87D92900}.Release|Any CPU.ActiveCfg = Release|Any CPU {695ECD3A-15DB-4B29-BC9D-E8CC87D92900}.Release|Any CPU.Build.0 = Release|Any CPU {695ECD3A-15DB-4B29-BC9D-E8CC87D92900}.Release|Any CPU.Deploy.0 = Release|Any CPU + {F96C29D3-33A7-4230-A1C7-799114865D52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F96C29D3-33A7-4230-A1C7-799114865D52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F96C29D3-33A7-4230-A1C7-799114865D52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F96C29D3-33A7-4230-A1C7-799114865D52}.Release|Any CPU.Build.0 = Release|Any CPU + {0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ParionsCuite/ParionsCuite/ParionsCuite.csproj b/ParionsCuite/ParionsCuite/ParionsCuite.csproj index 28533d5..9affd38 100644 --- a/ParionsCuite/ParionsCuite/ParionsCuite.csproj +++ b/ParionsCuite/ParionsCuite/ParionsCuite.csproj @@ -45,11 +45,17 @@ + + + + + + @@ -100,10 +106,8 @@ - - $(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll @@ -118,6 +122,9 @@ True + + + 3.1 diff --git a/ParionsCuite/TestParionsCuite/TestParionsCuite.csproj b/ParionsCuite/TestParionsCuite/TestParionsCuite.csproj new file mode 100644 index 0000000..321dc28 --- /dev/null +++ b/ParionsCuite/TestParionsCuite/TestParionsCuite.csproj @@ -0,0 +1,29 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/ParionsCuite/TestParionsCuite/UnitTest1.cs b/ParionsCuite/TestParionsCuite/UnitTest1.cs new file mode 100644 index 0000000..b040dde --- /dev/null +++ b/ParionsCuite/TestParionsCuite/UnitTest1.cs @@ -0,0 +1,17 @@ +using ParionsCuite.Modeles; + +namespace TestParionsCuite +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + Manageur manageur = new Manageur(); + if (manageur == null) + { + return; + } + } + } +} \ No newline at end of file diff --git a/ParionsCuite/TestParionsCuite/Usings.cs b/ParionsCuite/TestParionsCuite/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/ParionsCuite/TestParionsCuite/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file