diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs
index 351d39e..96a2700 100644
--- a/Sources/BowlingLib/Model/Frame.cs
+++ b/Sources/BowlingLib/Model/Frame.cs
@@ -36,6 +36,11 @@ namespace BowlingLib.Model
this.IsSpare = false;
}
+ ///
+ /// Lance une quille
+ ///
+ /// le nombre de quilles tombés
+ ///
public void Lancer(int quillesTombees)
{
if (quillesTombees > QuillesRestantes)
@@ -80,6 +85,7 @@ namespace BowlingLib.Model
if (quillesTombees + this.Lancer1.QuillesTombees == 10)
{
this.IsSpare = true;
+ QuillesRestantes = 10;
}
}
}
diff --git a/Sources/BowlingLib/Model/Partie.cs b/Sources/BowlingLib/Model/Partie.cs
index a9c1dcc..d591c9a 100644
--- a/Sources/BowlingLib/Model/Partie.cs
+++ b/Sources/BowlingLib/Model/Partie.cs
@@ -13,17 +13,30 @@ namespace BowlingLib.Model
public List Frames { get; set; }
+ ///
+ /// Constructeur
+ ///
+ ///
public Partie(Joueur joueur)
{
this.Joueur = joueur;
Frames = new List();
}
+ ///
+ /// Ajoute un frame à la partie
+ ///
+ ///
public void AddFrame(Frame frame)
{
Frames.Add(frame);
}
+
+ ///
+ /// Calcule le score de la partie
+ ///
+ /// le Score d'une partie
public int? GetScore()
{
int? score = 0;
diff --git a/Sources/Tests/BowlingAppUnitTest/UTPartie.cs b/Sources/Tests/BowlingAppUnitTest/UTPartie.cs
index 4177389..da4505b 100644
--- a/Sources/Tests/BowlingAppUnitTest/UTPartie.cs
+++ b/Sources/Tests/BowlingAppUnitTest/UTPartie.cs
@@ -68,7 +68,11 @@ namespace BowlingAppUnitTest
{
partie.Frames[i].Lancer(5);
partie.Frames[i].Lancer(5);
-
+ if (i == 9)
+ {
+ partie.Frames[i].Lancer(5);
+ }
+
}
//Act
@@ -109,6 +113,10 @@ namespace BowlingAppUnitTest
{
partie.Frames[i].Lancer(5);
partie.Frames[i].Lancer(5);
+ if (i==9)
+ {
+ partie.Frames[i].Lancer(5);
+ }
}
}
@@ -118,5 +126,39 @@ namespace BowlingAppUnitTest
//Assert
Assert.Equal(200, score);
}
+
+ //le cas ou le joueur ne fait aucun strike ou spare
+
+ [Fact]
+
+ public void TestGetScore4()
+ {
+ //Arrange
+ StubPartie stubPartie = new StubPartie();
+ List listParties = stubPartie.ListParties();
+ Partie partie = listParties[0];
+ partie.AddFrame(new Frame(1));
+ partie.AddFrame(new Frame(2));
+ partie.AddFrame(new Frame(3));
+ partie.AddFrame(new Frame(4));
+ partie.AddFrame(new Frame(5));
+ partie.AddFrame(new Frame(6));
+ partie.AddFrame(new Frame(7));
+ partie.AddFrame(new Frame(8));
+ partie.AddFrame(new Frame(9));
+ partie.AddFrame(new Frame(10));
+
+ for (int i = 0; i < partie.Frames.Count; i++)
+ {
+ partie.Frames[i].Lancer(5);
+ partie.Frames[i].Lancer(4);
+ }
+
+ //Act
+ int? score = partie.GetScore();
+
+ //Assert
+ Assert.Equal(90, score);
+ }
}
}
\ No newline at end of file