From a37c425ec80068ee2100de4a53e29b42f1cfaf5f Mon Sep 17 00:00:00 2001 From: Arafamamadouelaphi <92931011+Arafamamadouelaphi@users.noreply.github.com> Date: Sat, 22 Oct 2022 14:10:49 +0100 Subject: [PATCH 1/4] stupEquipe --- Sources/BowlingLib/Model/Equipe.cs | 13 +- Sources/BowlingLib/Model/Frame.cs | 28 ++-- Sources/BowlingLib/Model/Joueur.cs | 10 +- Sources/BowlingMaping/EquipeDbDataManager.cs | 3 +- Sources/BowlingStub/StubEquipe.cs | 4 +- Sources/BowlingStub/StubManager.cs | 28 ---- .../Tests/BowlingAppUnitTest/UTestEquipe.cs | 154 +++++++++--------- 7 files changed, 108 insertions(+), 132 deletions(-) delete mode 100644 Sources/BowlingStub/StubManager.cs diff --git a/Sources/BowlingLib/Model/Equipe.cs b/Sources/BowlingLib/Model/Equipe.cs index e22a31a..6b1206e 100644 --- a/Sources/BowlingLib/Model/Equipe.cs +++ b/Sources/BowlingLib/Model/Equipe.cs @@ -14,7 +14,7 @@ namespace BowlingLib.Model private readonly long id; - public List Joueurs = new List(); + private readonly List Joueurs = new List(); public string Nom @@ -44,10 +44,12 @@ namespace BowlingLib.Model this.nom = nom; } - public Equipe(long id, string nom, List joueurs) + public Equipe(long id, string nom, IEnumerable joueurs) + //liste implemente dautre methode a l indxeur + { this.id = id; - Joueurs = joueurs; + Joueurs.AddRange( joueurs); Nom = nom; } @@ -72,7 +74,8 @@ namespace BowlingLib.Model { Joueurs.Add(joueur); return true; - }else + } + else { return false; } @@ -84,7 +87,7 @@ namespace BowlingLib.Model } //retourner la liste non modifiable des joueurs de l'équipe - public List GetJoueurs() + public IEnumerable GetJoueurs() { return Joueurs; } diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs index ff00887..8e2d712 100644 --- a/Sources/BowlingLib/Model/Frame.cs +++ b/Sources/BowlingLib/Model/Frame.cs @@ -29,16 +29,14 @@ namespace BowlingLib.Model } - public int QuillesRestantes - { get - { - return quillesRestantes; - } - set + public int QuillesRestantes + { + get { - this.quillesRestantes = value; + return MAX_QUILLE - quillesTombees; } } + private int quillesRestantes; public int QuillesTombees @@ -124,7 +122,7 @@ namespace BowlingLib.Model public Frame(int numero) { this.Numero = numero; - this.QuillesRestantes = MAX_QUILLE; + // this.QuillesRestantes = MAX_QUILLE; this.IsFinished = false; this.IsStrike = false; this.IsSpare = false; @@ -169,12 +167,12 @@ namespace BowlingLib.Model throw new ArgumentException("Le nombre de quilles tombees doit et etre positif"); } - if (this.Numero == 10) + if (this.Numero == MAX_QUILLE) { if (this.Lancer1 == null) { this.Lancer1 = new Lancer(quillesTombees); - this.QuillesRestantes -= quillesTombees; + // this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (quillesTombees == MAX_QUILLE) { @@ -184,7 +182,7 @@ namespace BowlingLib.Model else if (this.Lancer2 == null) { this.Lancer2 = new Lancer(quillesTombees); - this.QuillesRestantes -= quillesTombees; + // this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (this.IsStrike) { @@ -202,14 +200,14 @@ namespace BowlingLib.Model if (quillesTombees + this.Lancer1.QuillesTombees == MAX_QUILLE) { this.IsSpare = true; - QuillesRestantes = 10; + // QuillesRestantes = 10; } } } else if (this.Lancer3 == null) { this.Lancer3 = new Lancer(quillesTombees); - this.QuillesRestantes -= quillesTombees; + // this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (this.IsStrike) { @@ -260,7 +258,7 @@ namespace BowlingLib.Model { throw new ArgumentException("Le nombre de lancers est deja atteint"); } - this.QuillesRestantes -= quillesTombees; + // this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (quillesTombees == MAX_QUILLE) { @@ -271,7 +269,7 @@ namespace BowlingLib.Model this.IsSpare = true; } } - if (this.QuillesRestantes == 0 || (this.Lancer2 != null && this.Numero != 10)) + if (this.QuillesRestantes == 0 || (this.Lancer2 != null && this.Numero != MAX_QUILLE)) { this.IsFinished = true; } diff --git a/Sources/BowlingLib/Model/Joueur.cs b/Sources/BowlingLib/Model/Joueur.cs index 11fef50..4578dbb 100644 --- a/Sources/BowlingLib/Model/Joueur.cs +++ b/Sources/BowlingLib/Model/Joueur.cs @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace BowlingLib.Model { - public class Joueur + public class Joueur + //IEquatable { private string pseudo; private readonly long id; @@ -40,14 +41,17 @@ namespace BowlingLib.Model } public override bool Equals(object obj) - { + { + if (ReferenceEquals(obj, null)) return false; + if(ReferenceEquals(obj,this)) return true; + return obj is Joueur joueur && pseudo == joueur.pseudo && Pseudo == joueur.Pseudo; } public override int GetHashCode() - { + {//getHashcode utiliser par le set retur un codehch video sur dictionnaire return HashCode.Combine(id, Id, Pseudo); } } diff --git a/Sources/BowlingMaping/EquipeDbDataManager.cs b/Sources/BowlingMaping/EquipeDbDataManager.cs index b1f583d..b033be6 100644 --- a/Sources/BowlingMaping/EquipeDbDataManager.cs +++ b/Sources/BowlingMaping/EquipeDbDataManager.cs @@ -1,4 +1,5 @@ -using BowlingEF.Context; + +using BowlingEF.Context; using BowlingEF.Entities; using BowlingLib.Model; using Business; diff --git a/Sources/BowlingStub/StubEquipe.cs b/Sources/BowlingStub/StubEquipe.cs index bbfd5b5..7561756 100644 --- a/Sources/BowlingStub/StubEquipe.cs +++ b/Sources/BowlingStub/StubEquipe.cs @@ -10,9 +10,7 @@ namespace BowlingStub public int nbrJ = 10,nbrE = 2; public StubEquipe() { - //listEquipes.Add(new Equipe("Equipe 1", new Joueur("Joueur 1"), new Joueur("Joueur 2"))); - //listEquipes.Add(new Equipe("Equipe 2", new Joueur("Joueur 3"), new Joueur("Joueur 4"))); - //listEquipes.Add(new Equipe("Equipe 3", new Joueur("Joueur 5"), new Joueur("Joueur 6"))); + } public bool Add(Equipe data) diff --git a/Sources/BowlingStub/StubManager.cs b/Sources/BowlingStub/StubManager.cs deleted file mode 100644 index 167bff7..0000000 --- a/Sources/BowlingStub/StubManager.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BowlingLib.Model; -using Business; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BowlingStub -{ - internal class StubManager - { - private List lesjoueurs = new List(); - private List parties = new List(); - private List equipes = new List(); - - public void Add(Manager data) - { - - } - - public void Delete(Manager data) - { - - } - - } -} diff --git a/Sources/Tests/BowlingAppUnitTest/UTestEquipe.cs b/Sources/Tests/BowlingAppUnitTest/UTestEquipe.cs index 2aadf85..f67c458 100644 --- a/Sources/Tests/BowlingAppUnitTest/UTestEquipe.cs +++ b/Sources/Tests/BowlingAppUnitTest/UTestEquipe.cs @@ -1,86 +1,86 @@ -using System; -using System.Collections.Generic; +using System; +using System.Collections.Generic; using BowlingLib.Model; -using Xunit; - -namespace Test.BowlingAppUnitTest -{ - public class UnitTestEquipe - { - - public static IEnumerable Data_AddJoueurToEquipe() - { - yield return new object[] - { - true, - new Joueur[] - { - new Joueur("Alys"), - new Joueur("Bénita"), - new Joueur("Regis"), - new Joueur("Mania"), - new Joueur("Cornelle") - }, - new Equipe("ABRMC", - new Joueur("Alys"), - new Joueur("Bénita"), - new Joueur("Regis"), - new Joueur("Mania")), - new Joueur("Cornelle") - }; - - yield return new object[] - { - false, - new Joueur[] - { - new Joueur("Alys"), - new Joueur("Bénita"), - new Joueur("Regis"), - new Joueur("Mania") - }, - new Equipe("ABRMC", - new Joueur("Alys"), - new Joueur("Bénita"), - new Joueur("Regis"), - new Joueur("Mania")), - new Joueur("Mania") - }; - } - - - [Theory] - [MemberData(nameof(Data_AddJoueurToEquipe))] - public void Test_AddJoueurToEquipe(bool expectedResult, - Joueur[] expectedJoueurs, - Equipe equipe, - Joueur joueur) - { - - bool result = equipe.AjouterJoueur(joueur); - Assert.Equal(expectedResult, result); - Assert.Equal(expectedJoueurs.Length, equipe.GetJoueurs().Count); - Assert.All(expectedJoueurs, j => equipe.Joueurs.Contains(j)); +using Xunit; + +namespace Test.BowlingAppUnitTest +{ + public class UnitTestEquipe + { + + public static IEnumerable Data_AddJoueurToEquipe() + { + yield return new object[] + { + true, + new Joueur[] + { + new Joueur("Alys"), + new Joueur("Bénita"), + new Joueur("Regis"), + new Joueur("Mania"), + new Joueur("Cornelle") + }, + new Equipe("ABRMC", + new Joueur("Alys"), + new Joueur("Bénita"), + new Joueur("Regis"), + new Joueur("Mania")), + new Joueur("Cornelle") + }; + + yield return new object[] + { + false, + new Joueur[] + { + new Joueur("Alys"), + new Joueur("Bénita"), + new Joueur("Regis"), + new Joueur("Mania") + }, + new Equipe("ABRMC", + new Joueur("Alys"), + new Joueur("Bénita"), + new Joueur("Regis"), + new Joueur("Mania")), + new Joueur("Mania") + }; + } + + + [Theory] + [MemberData(nameof(Data_AddJoueurToEquipe))] + public void Test_AddJoueurToEquipe(bool expectedResult, + Joueur[] expectedJoueurs, + Equipe equipe, + Joueur joueur) + { + + bool result = equipe.AjouterJoueur(joueur); + Assert.Equal(expectedResult, result); + Assert.Equal(expectedJoueurs.Length, equipe.GetJoueurs().Count); + Assert.All(expectedJoueurs, j => equipe.Joueurs.Contains(j)); } [Theory] - [MemberData(nameof(TestData.Data_AddJoueurToEquipe), MemberType=typeof(TestData))] + [MemberData(nameof(TestData.Data_AddJoueurToEquipe), MemberType=typeof(TestData))] public void Test_AddJoueursToEquipe(int expectedResult, Joueur[] expectedJoueurs, Joueur[] expectedAddedJoueurs, Equipe equipe, - params Joueur[] joueursToAdd) - { - var addedJoueurs = equipe.AjouterJoueurs(joueursToAdd); - Assert.Equal(expectedResult, addedJoueurs.Count); - - Assert.All(expectedAddedJoueurs, a => addedJoueurs.Contains(a)); - - Assert.Equal(expectedJoueurs.Length, equipe.Joueurs.Count); - Assert.All(expectedJoueurs, a => equipe.Joueurs.Contains(a)); - } - - - } -} + params Joueur[] joueursToAdd) + { + var addedJoueurs = equipe.AjouterJoueurs(joueursToAdd); + Assert.Equal(expectedResult, addedJoueurs.Count); + + Assert.All(expectedAddedJoueurs, a => addedJoueurs.Contains(a)); + + Assert.Equal(expectedJoueurs.Length, equipe.Joueurs.Count); + Assert.All(expectedJoueurs, a => equipe.Joueurs.Contains(a)); + } + + + } +} From 77e5e8c1cbf3b2ca481fceb60af80ddc0c5909b6 Mon Sep 17 00:00:00 2001 From: victor perez ngounou Date: Sat, 22 Oct 2022 15:00:20 +0200 Subject: [PATCH 2/4] . --- Sources/BowlingLib/Model/Equipe.cs | 8 +++----- Sources/BowlingLib/Model/Frame.cs | 16 ++++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Sources/BowlingLib/Model/Equipe.cs b/Sources/BowlingLib/Model/Equipe.cs index 290c04e..65c2df7 100644 --- a/Sources/BowlingLib/Model/Equipe.cs +++ b/Sources/BowlingLib/Model/Equipe.cs @@ -15,9 +15,8 @@ namespace BowlingLib.Model { private string nom; private readonly long id; - - - private readonly List Joueurs = new List(); + + public List Joueurs = new List(); public string Nom @@ -32,8 +31,7 @@ namespace BowlingLib.Model public Equipe(string nom, params Joueur[] joueurs) { this.nom = nom; - AjouterJoueurs(joueurs); - // foreach (Joueur nouv in joueurs) AjouterJoueur(nouv); + AjouterJoueurs(joueurs); } public long Id diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs index 4189580..ee9410d 100644 --- a/Sources/BowlingLib/Model/Frame.cs +++ b/Sources/BowlingLib/Model/Frame.cs @@ -37,7 +37,11 @@ namespace BowlingLib.Model { get { - return MAX_QUILLE - quillesTombees; + return quillesRestantes; + } + private set + { + this.quillesRestantes = value; } } @@ -129,7 +133,7 @@ namespace BowlingLib.Model public Frame(int numero) { this.Numero = numero; - // this.QuillesRestantes = MAX_QUILLE; + this.QuillesRestantes = MAX_QUILLE; this.IsFinished = false; this.IsStrike = false; this.IsSpare = false; @@ -173,7 +177,7 @@ namespace BowlingLib.Model if (this.Lancer1 == null) { this.Lancer1 = new Lancer(quillesTombees); - // this.QuillesRestantes -= quillesTombees; + this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (quillesTombees == MAX_QUILLE) { @@ -184,7 +188,7 @@ namespace BowlingLib.Model else if (this.Lancer2 == null) { this.Lancer2 = new Lancer(quillesTombees); - // this.QuillesRestantes -= quillesTombees; + this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; //lorsque le premier lancer est un strike if (this.IsStrike) @@ -213,7 +217,7 @@ namespace BowlingLib.Model else if (this.Lancer3 == null) { this.Lancer3 = new Lancer(quillesTombees); - // this.QuillesRestantes -= quillesTombees; + this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (this.IsStrike)//si le deuxième lancer etait un strike { @@ -264,7 +268,7 @@ namespace BowlingLib.Model { throw new ArgumentException("Le nombre de lancers est deja atteint"); } - // this.QuillesRestantes -= quillesTombees; + this.QuillesRestantes -= quillesTombees; this.QuillesTombees += quillesTombees; if (quillesTombees == MAX_QUILLE) { From f835db04e6fe701bac59549d49a5739fcc00c6e3 Mon Sep 17 00:00:00 2001 From: Augustin AFFOGNON Date: Sat, 22 Oct 2022 17:20:10 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d1b279a..45f5908 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ [![Bugs](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=bugs&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) [![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=code_smells)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) [![Coverage](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=coverage&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Duplicated Lines (%)](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=duplicated_lines_density)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Lines of Code](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=ncloc)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Maintainability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=sqale_rating)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Reliability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=reliability_rating)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Security Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=security_rating)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Technical Debt](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=sqale_index)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=vulnerabilities)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Duplicated Lines (%)](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=duplicated_lines_density&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Lines of Code](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=ncloc&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Maintainability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=sqale_rating&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Reliability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=reliability_rating&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Security Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=security_rating&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Technical Debt](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=sqale_index&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=vulnerabilities&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) # BowlingScoreApp From 6e84510f5b84c39180a807a3b273a2cce3bfce7a Mon Sep 17 00:00:00 2001 From: Augustin AFFOGNON Date: Sat, 22 Oct 2022 17:20:59 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45f5908..db35a73 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Build Status](https://codefirst.iut.uca.fr/api/badges/victor_perez.ngounou/BowlingScoreApp/status.svg)](https://codefirst.iut.uca.fr/victor_perez.ngounou/BowlingScoreApp) [![Quality Gate Status](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=alert_status&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) [![Bugs](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=bugs&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) -[![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=code_smells)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) +[![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=code_smells&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) [![Coverage](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=coverage&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) [![Duplicated Lines (%)](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=duplicated_lines_density&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp) [![Lines of Code](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=BowlingScoreApp&metric=ncloc&token=d89d41f6a247037395d41fe6f40f53a402943bd9)](https://codefirst.iut.uca.fr/sonar/dashboard?id=BowlingScoreApp)