From 4d6052fc9baa5d25dd0271efccec8516b4ef01ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20F=C3=A9lix?= <felixantoine67@yahoo.fr>
Date: Wed, 1 Apr 2020 15:15:49 +0200
Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20classe=20"Libele.cs"=20pour=20a?=
 =?UTF-8?q?cc=C3=A9der=20aux=20libel=C3=A9s.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../psychorientation/InterfaceClasse.cs       | 25 +++++++--------
 psychorientation/psychorientation/Libele.cs   | 31 +++++++++++++++++--
 .../psychorientation/psychorientation.csproj  |  1 +
 3 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/psychorientation/psychorientation/InterfaceClasse.cs b/psychorientation/psychorientation/InterfaceClasse.cs
index 0b23140..c0a4760 100644
--- a/psychorientation/psychorientation/InterfaceClasse.cs
+++ b/psychorientation/psychorientation/InterfaceClasse.cs
@@ -12,12 +12,9 @@ namespace psychorientation
 {
     public partial class InterfaceClasse : Form
     {
-        private List<String> libele_mois = new List<String>()
-        {"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"};
-        private List<String> libele_niveau = new List<String>()
-        {"Seconde", "Première", "Terminale"};
-        private int mois_actuel = 8;
-        private int annee_actuelle = 0;
+        private Libele libele = Libele.GetInstance();
+        private int moisActuel = 8;
+        private int anneeActuelle = 0;
 
         public InterfaceClasse()
         {
@@ -27,7 +24,7 @@ namespace psychorientation
 
         private void Form1_Load(object sender, EventArgs e)
         {
-            lbl_date.Text = libele_mois[(mois_actuel % 12)] + " " + libele_niveau[annee_actuelle];
+            lbl_date.Text = libele.Mois(moisActuel % 12) + " " + libele.Niveau(anneeActuelle);
 
             TypeMessage tm = TypeMessage.INFORMATION;
             Message m = new Message(-1,"Bonjour apprenti prof, vous allez apprendre à éduquer des joueurs !! ", "Début", tm);
@@ -44,16 +41,16 @@ namespace psychorientation
             }
 
             // Passe au mois suivant.
-            mois_actuel++;
-            switch(mois_actuel)
+            moisActuel++;
+            switch(moisActuel)
             {
                 case 17: // Fin de la 1ère année : Début Juin.
-                    mois_actuel = 20;
-                    annee_actuelle = 1;
+                    moisActuel = 20;
+                    anneeActuelle = 1;
                     break;
                 case 29: // Fin de la 2nde année : Début Juin.
-                    mois_actuel = 32;
-                    annee_actuelle = 2;
+                    moisActuel = 32;
+                    anneeActuelle = 2;
                     break;
                 case 42: // Fin de la 3ème année : Debut Juillet.
                     // Fin de la partie.
@@ -68,7 +65,7 @@ namespace psychorientation
                     break;
             }
 
-            lbl_date.Text = libele_mois[(mois_actuel % 12)] + " " + libele_niveau[annee_actuelle];
+            lbl_date.Text = libele.Mois(moisActuel % 12) + " " + libele.Niveau(anneeActuelle);
         }
 
         private void Pb_liste_eleves_Click(object sender, EventArgs e)
diff --git a/psychorientation/psychorientation/Libele.cs b/psychorientation/psychorientation/Libele.cs
index 5eb215a..fb5008c 100644
--- a/psychorientation/psychorientation/Libele.cs
+++ b/psychorientation/psychorientation/Libele.cs
@@ -8,8 +8,35 @@ namespace psychorientation
 {
     class Libele
     {
-        private List<String> libele_mois;
-        private List<String> libele_niveau;
+        private List<string> libele_mois = new List<string>()
+        {"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"};
+        private List<string> libele_niveau = new List<string>()
+        {"Seconde", "Première", "Terminale"};
         private static Libele instance;
+
+        public Libele() {}
+
+        public static Libele GetInstance()
+        {
+            if(Libele.instance == null)
+            {
+                Libele.instance = new Libele();
+                return Libele.instance;
+            }
+            else
+            {
+                return Libele.instance;
+            }
+        }
+
+        public string Mois(int n)
+        {
+            return this.libele_mois[n];
+        }
+
+        public string Niveau(int n)
+        {
+            return this.libele_niveau[n];
+        }
     }
 }
diff --git a/psychorientation/psychorientation/psychorientation.csproj b/psychorientation/psychorientation/psychorientation.csproj
index 14e3ac1..e736d67 100644
--- a/psychorientation/psychorientation/psychorientation.csproj
+++ b/psychorientation/psychorientation/psychorientation.csproj
@@ -64,6 +64,7 @@
     <Compile Include="InterfaceInfoEleve.Designer.cs">
       <DependentUpon>InterfaceInfoEleve.cs</DependentUpon>
     </Compile>
+    <Compile Include="Libele.cs" />
     <Compile Include="Message.cs">
       <SubType>Form</SubType>
     </Compile>
-- 
GitLab