From 18f1fd95d2e6d1c5289b881eb3ce37f962f180fc Mon Sep 17 00:00:00 2001 From: Loris OBRY Date: Wed, 31 May 2023 15:20:27 +0200 Subject: [PATCH 1/6] Commentaire et Icontenu --- Sources/ConsoleApp/FileName.cs | 1 + Sources/Model/Carte.cs | 7 +++---- Sources/Model/Commentaire.cs | 20 ++++++++++++++++++++ Sources/Model/IContenu.cs | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Sources/Model/Commentaire.cs create mode 100644 Sources/Model/IContenu.cs diff --git a/Sources/ConsoleApp/FileName.cs b/Sources/ConsoleApp/FileName.cs index 3ab4062..26e9d95 100644 --- a/Sources/ConsoleApp/FileName.cs +++ b/Sources/ConsoleApp/FileName.cs @@ -25,6 +25,7 @@ namespace ConsoleApp */ Carte C = new Carte("Villageois", "Aucuns", "Doit voter inteligemment", null, "lien", "une carte peu apprécié mais necesaire"); + Console.WriteLine(C.Nom); } static void DisplayTab(string name, int[] tab) diff --git a/Sources/Model/Carte.cs b/Sources/Model/Carte.cs index 9479b48..d9d5027 100644 --- a/Sources/Model/Carte.cs +++ b/Sources/Model/Carte.cs @@ -9,7 +9,7 @@ using System.Runtime.CompilerServices; namespace Model { - public class Carte : INotifyPropertyChanged + public class Carte : IContenu, INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; void OnPropertyChanged([CallerMemberName] string ?propertyName = null) @@ -17,8 +17,7 @@ namespace Model PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - private readonly string nom; - public string Nom => nom; + public string Nom { get; set; } public string Description { get => description; set { @@ -76,7 +75,7 @@ namespace Model private string lienImage; public Carte(string nom, string pouvoir, string strategie, int? note, string lienImage, string description) { - this.nom = nom; + this.Nom = nom; this.description = description; this.pouvoir = pouvoir; this.strategie = strategie; diff --git a/Sources/Model/Commentaire.cs b/Sources/Model/Commentaire.cs new file mode 100644 index 0000000..f658a66 --- /dev/null +++ b/Sources/Model/Commentaire.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + internal class Commentaire + { + public string texte { get; set; } + public Utilisateur Proprietaire { get; set; } + public IContenu Contenu { get; set; } + Commentaire(string contenu, Utilisateur Proprietaire) + { + this.Contenu = Contenu; + this.Proprietaire = Proprietaire; + } + } +} diff --git a/Sources/Model/IContenu.cs b/Sources/Model/IContenu.cs new file mode 100644 index 0000000..ea577fd --- /dev/null +++ b/Sources/Model/IContenu.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public interface IContenu + { + public string Nom { get; set; } + public string Description { get; set; } + public int? Note { get; set; } + } +} From 067a5ca9c599b9dca76d341aa607dfb3bff18d1a Mon Sep 17 00:00:00 2001 From: Loris OBRY Date: Wed, 31 May 2023 15:21:52 +0200 Subject: [PATCH 2/6] fix commentaire ctr --- Sources/Model/Commentaire.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/Model/Commentaire.cs b/Sources/Model/Commentaire.cs index f658a66..e31f114 100644 --- a/Sources/Model/Commentaire.cs +++ b/Sources/Model/Commentaire.cs @@ -8,13 +8,14 @@ namespace Model { internal class Commentaire { - public string texte { get; set; } + public string Texte { get; set; } public Utilisateur Proprietaire { get; set; } - public IContenu Contenu { get; set; } - Commentaire(string contenu, Utilisateur Proprietaire) + public IContenu ContenuCommente { get; set; } + public Commentaire(string Texte, Utilisateur Proprietaire, IContenu ContenuCommente) { - this.Contenu = Contenu; + this.Texte = Texte; this.Proprietaire = Proprietaire; + this.ContenuCommente = ContenuCommente; } } } From 1d23609474c342f5ba823e1ca66c22287b047019 Mon Sep 17 00:00:00 2001 From: Loris OBRY Date: Wed, 31 May 2023 16:08:30 +0200 Subject: [PATCH 3/6] Ajout de la liste de commentaire dans carte --- Sources/ConsoleApp/FileName.cs | 3 +++ Sources/Model/Carte.cs | 4 ++- Sources/Model/Commentaire.cs | 4 +-- Sources/Model/Pack.cs | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 Sources/Model/Pack.cs diff --git a/Sources/ConsoleApp/FileName.cs b/Sources/ConsoleApp/FileName.cs index 26e9d95..7f1c623 100644 --- a/Sources/ConsoleApp/FileName.cs +++ b/Sources/ConsoleApp/FileName.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Emit; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; @@ -25,7 +26,9 @@ namespace ConsoleApp */ Carte C = new Carte("Villageois", "Aucuns", "Doit voter inteligemment", null, "lien", "une carte peu apprécié mais necesaire"); + Pack P = new Pack("Jeu de base", "C'est la premiere version du jeu", 5); Console.WriteLine(C.Nom); + Console.WriteLine(P.Nom); } static void DisplayTab(string name, int[] tab) diff --git a/Sources/Model/Carte.cs b/Sources/Model/Carte.cs index d9d5027..06e02c0 100644 --- a/Sources/Model/Carte.cs +++ b/Sources/Model/Carte.cs @@ -72,6 +72,7 @@ namespace Model OnPropertyChanged(nameof(LienImage)); } } + public IEnumerable ContenuList { get; set; } private string lienImage; public Carte(string nom, string pouvoir, string strategie, int? note, string lienImage, string description) { @@ -80,7 +81,8 @@ namespace Model this.pouvoir = pouvoir; this.strategie = strategie; this.note = note; - this.lienImage = LienImage; + this.lienImage = lienImage; + this.ContenuList = new List(); } } } diff --git a/Sources/Model/Commentaire.cs b/Sources/Model/Commentaire.cs index e31f114..fb4e7af 100644 --- a/Sources/Model/Commentaire.cs +++ b/Sources/Model/Commentaire.cs @@ -10,12 +10,10 @@ namespace Model { public string Texte { get; set; } public Utilisateur Proprietaire { get; set; } - public IContenu ContenuCommente { get; set; } - public Commentaire(string Texte, Utilisateur Proprietaire, IContenu ContenuCommente) + public Commentaire(string Texte, Utilisateur Proprietaire) { this.Texte = Texte; this.Proprietaire = Proprietaire; - this.ContenuCommente = ContenuCommente; } } } diff --git a/Sources/Model/Pack.cs b/Sources/Model/Pack.cs new file mode 100644 index 0000000..79efae0 --- /dev/null +++ b/Sources/Model/Pack.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace Model +{ + public class Pack : IContenu, INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + public string Nom { get; set; } + public string Description { get; set; } + private int? note; + public int? Note + { + get + { + return note; + } + set + { + if (value < 0 || value > 10) + { + throw new ArgumentOutOfRangeException(nameof(value), "La valeur de la note doit être comprise entre 0 et 10."); + } + note = value; + OnPropertyChanged(nameof(Note)); + } + } + public Pack(string nom, string description, int? note) + { + Nom = nom; + Description = description; + Note = note; + } + } +} From 45dfdb77d66b18bbcb1e6d06134e450a44d3ef77 Mon Sep 17 00:00:00 2001 From: Loris OBRY Date: Wed, 31 May 2023 16:25:16 +0200 Subject: [PATCH 4/6] Passage en List pour les commentaires, ajout du OnPropertyCHange pour le pack et les commentaires et quelques corrections dans le code --- Sources/Model/Carte.cs | 15 ++++++++++++--- Sources/Model/Pack.cs | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Sources/Model/Carte.cs b/Sources/Model/Carte.cs index 06e02c0..9264597 100644 --- a/Sources/Model/Carte.cs +++ b/Sources/Model/Carte.cs @@ -67,12 +67,21 @@ namespace Model get => lienImage; set { - if (!string.IsNullOrEmpty(lienImage)) lienImage = "notfound"; + if (string.IsNullOrEmpty(lienImage)) lienImage = "notfound"; else lienImage = value; OnPropertyChanged(nameof(LienImage)); } } - public IEnumerable ContenuList { get; set; } + public List commentaires; + public List Commentaires + { + get => commentaires; + set + { + commentaires = value; + OnPropertyChanged(nameof(Commentaires)); + } + } private string lienImage; public Carte(string nom, string pouvoir, string strategie, int? note, string lienImage, string description) { @@ -82,7 +91,7 @@ namespace Model this.strategie = strategie; this.note = note; this.lienImage = lienImage; - this.ContenuList = new List(); + this.commentaires = new List(); } } } diff --git a/Sources/Model/Pack.cs b/Sources/Model/Pack.cs index 79efae0..06bc9ca 100644 --- a/Sources/Model/Pack.cs +++ b/Sources/Model/Pack.cs @@ -16,9 +16,25 @@ namespace Model { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - - public string Nom { get; set; } - public string Description { get; set; } + public string nom; + public string Nom + { + get => nom; + set + { + nom = value; + OnPropertyChanged(nameof(Nom)); + } + } + public string description; + public string Description { + get => description; + set + { + nom = value; + OnPropertyChanged(nameof(Description)); + } + } private int? note; public int? Note { @@ -36,11 +52,22 @@ namespace Model OnPropertyChanged(nameof(Note)); } } + public List commentaires; + public List Commentaires + { + get => commentaires; + set + { + commentaires = value; + OnPropertyChanged(nameof(Commentaires)); + } + } public Pack(string nom, string description, int? note) { - Nom = nom; - Description = description; - Note = note; + this.nom = nom; + this.description = description; + this.note = note; + this.commentaires = new List(); } } } From 4da35da005a2cc7e2b870dec72a09b4bceed8503 Mon Sep 17 00:00:00 2001 From: Loris OBRY Date: Wed, 31 May 2023 16:35:32 +0200 Subject: [PATCH 5/6] ajout de camp.cs --- Sources/Model/Camp.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Sources/Model/Camp.cs diff --git a/Sources/Model/Camp.cs b/Sources/Model/Camp.cs new file mode 100644 index 0000000..b84ea25 --- /dev/null +++ b/Sources/Model/Camp.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public class Camp + { + public string Nom { get; set; } + public string Description { get; set; } + public string LienImage { get; set; } + public List Cartes { get; set; } + public Camp(string Nom, string Description, string LienImage) + { + this.Nom = Nom; + this.Description = Description; + this.LienImage = LienImage; + this.Cartes = new List(); + } + } +} From 0a7ee831209150d57559f3fd788a747cf8001bf5 Mon Sep 17 00:00:00 2001 From: Loris OBRY Date: Wed, 31 May 2023 16:53:07 +0200 Subject: [PATCH 6/6] Ajout dossier Classes --- Sources/ConsoleApp/FileName.cs | 8 +++++--- Sources/MauiApp1/MainPage.xaml.cs | 2 +- Sources/Model/{ => Classes}/Camp.cs | 4 ++-- Sources/Model/{ => Classes}/Carte.cs | 19 +++++++++++-------- Sources/Model/{ => Classes}/Commentaire.cs | 4 ++-- Sources/Model/{ => Classes}/IContenu.cs | 2 +- Sources/Model/{ => Classes}/IDataManager.cs | 2 +- Sources/Model/{ => Classes}/Manager.cs | 6 +++--- Sources/Model/{ => Classes}/Pack.cs | 9 +++++---- Sources/Model/{ => Classes}/Utilisateur.cs | 2 +- 10 files changed, 32 insertions(+), 26 deletions(-) rename Sources/Model/{ => Classes}/Camp.cs (86%) rename Sources/Model/{ => Classes}/Carte.cs (86%) rename Sources/Model/{ => Classes}/Commentaire.cs (84%) rename Sources/Model/{ => Classes}/IContenu.cs (88%) rename Sources/Model/{ => Classes}/IDataManager.cs (90%) rename Sources/Model/{ => Classes}/Manager.cs (90%) rename Sources/Model/{ => Classes}/Pack.cs (90%) rename Sources/Model/{ => Classes}/Utilisateur.cs (94%) diff --git a/Sources/ConsoleApp/FileName.cs b/Sources/ConsoleApp/FileName.cs index 7f1c623..17748ae 100644 --- a/Sources/ConsoleApp/FileName.cs +++ b/Sources/ConsoleApp/FileName.cs @@ -1,4 +1,4 @@ -using Model; +using Model.Classes; using System; using System.Collections.Generic; using System.Linq; @@ -25,10 +25,12 @@ namespace ConsoleApp DisplayTab("Tableau 2 :", tab2); */ - Carte C = new Carte("Villageois", "Aucuns", "Doit voter inteligemment", null, "lien", "une carte peu apprécié mais necesaire"); + Utilisateur Kylian = new("Kyky", "12345", null); + Carte C = new("Villageois", "Aucuns", "Doit voter inteligemment", null, "lien", "une carte peu apprécié mais necesaire"); + C.commentaires.Add(new Commentaire("Cette carte est la base du jeu, cool pour les debutants", Kylian )); Pack P = new Pack("Jeu de base", "C'est la premiere version du jeu", 5); - Console.WriteLine(C.Nom); Console.WriteLine(P.Nom); + Console.WriteLine(C.commentaires[0]); } static void DisplayTab(string name, int[] tab) diff --git a/Sources/MauiApp1/MainPage.xaml.cs b/Sources/MauiApp1/MainPage.xaml.cs index f1a8dc4..b732139 100644 --- a/Sources/MauiApp1/MainPage.xaml.cs +++ b/Sources/MauiApp1/MainPage.xaml.cs @@ -1,4 +1,4 @@ -using Model; +using Model.Classes; using System.Diagnostics; namespace MauiApp1; diff --git a/Sources/Model/Camp.cs b/Sources/Model/Classes/Camp.cs similarity index 86% rename from Sources/Model/Camp.cs rename to Sources/Model/Classes/Camp.cs index b84ea25..246f4c8 100644 --- a/Sources/Model/Camp.cs +++ b/Sources/Model/Classes/Camp.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Model +namespace Model.Classes { public class Camp { @@ -17,7 +17,7 @@ namespace Model this.Nom = Nom; this.Description = Description; this.LienImage = LienImage; - this.Cartes = new List(); + Cartes = new List(); } } } diff --git a/Sources/Model/Carte.cs b/Sources/Model/Classes/Carte.cs similarity index 86% rename from Sources/Model/Carte.cs rename to Sources/Model/Classes/Carte.cs index 9264597..2699ba2 100644 --- a/Sources/Model/Carte.cs +++ b/Sources/Model/Classes/Carte.cs @@ -7,26 +7,29 @@ using System.Threading.Tasks; using System.ComponentModel; using System.Runtime.CompilerServices; -namespace Model +namespace Model.Classes { public class Carte : IContenu, INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; - void OnPropertyChanged([CallerMemberName] string ?propertyName = null) + void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } public string Nom { get; set; } - public string Description { + public string Description + { get => description; - set { + set + { description = value; OnPropertyChanged(nameof(Description)); - } + } } private string description; - public string Pouvoir { + public string Pouvoir + { get => pouvoir; set { @@ -85,13 +88,13 @@ namespace Model private string lienImage; public Carte(string nom, string pouvoir, string strategie, int? note, string lienImage, string description) { - this.Nom = nom; + Nom = nom; this.description = description; this.pouvoir = pouvoir; this.strategie = strategie; this.note = note; this.lienImage = lienImage; - this.commentaires = new List(); + commentaires = new List(); } } } diff --git a/Sources/Model/Commentaire.cs b/Sources/Model/Classes/Commentaire.cs similarity index 84% rename from Sources/Model/Commentaire.cs rename to Sources/Model/Classes/Commentaire.cs index fb4e7af..6ae2d3a 100644 --- a/Sources/Model/Commentaire.cs +++ b/Sources/Model/Classes/Commentaire.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Model +namespace Model.Classes { - internal class Commentaire + public class Commentaire { public string Texte { get; set; } public Utilisateur Proprietaire { get; set; } diff --git a/Sources/Model/IContenu.cs b/Sources/Model/Classes/IContenu.cs similarity index 88% rename from Sources/Model/IContenu.cs rename to Sources/Model/Classes/IContenu.cs index ea577fd..02ae49a 100644 --- a/Sources/Model/IContenu.cs +++ b/Sources/Model/Classes/IContenu.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Model +namespace Model.Classes { public interface IContenu { diff --git a/Sources/Model/IDataManager.cs b/Sources/Model/Classes/IDataManager.cs similarity index 90% rename from Sources/Model/IDataManager.cs rename to Sources/Model/Classes/IDataManager.cs index 36847a2..77cd68b 100644 --- a/Sources/Model/IDataManager.cs +++ b/Sources/Model/Classes/IDataManager.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Model +namespace Model.Classes { public interface IDataManager { diff --git a/Sources/Model/Manager.cs b/Sources/Model/Classes/Manager.cs similarity index 90% rename from Sources/Model/Manager.cs rename to Sources/Model/Classes/Manager.cs index b5b8311..104634e 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Classes/Manager.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using System.Collections.ObjectModel; using System.Data; -namespace Model +namespace Model.Classes { public class Manager : IDataManager { @@ -16,7 +16,7 @@ namespace Model private IDataManager DataMgr { get; set; } public Manager(IDataManager dataManager) { - DataMgr = dataManager; + DataMgr = dataManager; Cartes = new(cartes); } public bool AddCarte(Carte carte) @@ -26,7 +26,7 @@ namespace Model if (cartes.Contains(carte)) return false; cartes.Add(carte); - DataMgr.AddCarte(carte); + DataMgr.AddCarte(carte); return true; } diff --git a/Sources/Model/Pack.cs b/Sources/Model/Classes/Pack.cs similarity index 90% rename from Sources/Model/Pack.cs rename to Sources/Model/Classes/Pack.cs index 06bc9ca..d6da655 100644 --- a/Sources/Model/Pack.cs +++ b/Sources/Model/Classes/Pack.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using System.ComponentModel; using System.Runtime.CompilerServices; -namespace Model +namespace Model.Classes { public class Pack : IContenu, INotifyPropertyChanged { @@ -27,14 +27,15 @@ namespace Model } } public string description; - public string Description { + public string Description + { get => description; set { nom = value; OnPropertyChanged(nameof(Description)); } - } + } private int? note; public int? Note { @@ -67,7 +68,7 @@ namespace Model this.nom = nom; this.description = description; this.note = note; - this.commentaires = new List(); + commentaires = new List(); } } } diff --git a/Sources/Model/Utilisateur.cs b/Sources/Model/Classes/Utilisateur.cs similarity index 94% rename from Sources/Model/Utilisateur.cs rename to Sources/Model/Classes/Utilisateur.cs index b9d602e..7947e38 100644 --- a/Sources/Model/Utilisateur.cs +++ b/Sources/Model/Classes/Utilisateur.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using System.ComponentModel; using System.Runtime.CompilerServices; -namespace Model +namespace Model.Classes { public class Utilisateur : INotifyPropertyChanged {