public void SiLePremierLancerFaittombeLes10QuillesOnAUnStrike()
        {
            var bowling = new Bowling();

            bowling.Lance(10);
            Assert.AreEqual(Lancer.Strike, bowling.ResultatLancer);
        }
        public void LePremierLancerNonStrikeEstNormal()
        {
            var bowling = new Bowling();

            bowling.Lance(5);
            Assert.AreEqual(Lancer.Normal, bowling.ResultatLancer);
        }
        public void ApresPremierLancerOnPeutFaireTomber10moinsXQuilles()
        {
            var bowling = new Bowling();

            bowling.Lance(6);
            Assert.AreEqual(4, bowling.Quilles);
        }
Beispiel #4
0
        public Form1()

        {
            const int MAX = 10;

            objectRef = new Bowling(MAX);
            InitializeComponent();
        }
        public void SiLes2LancerFontTomber10QuillesLeLancerEstUnSpare()
        {
            var bowling = new Bowling();

            bowling.Lance(6);
            bowling.Lance(4);
            Assert.AreEqual(Lancer.Spare, bowling.ResultatLancer);
        }
        public void ALaProchaineFrameOnDoitLancer10Quilles()
        {
            var bowling = new Bowling();

            bowling.Lance(5);
            bowling.Lance(4);
            Assert.AreEqual(10, bowling.Quilles);
        }
        public void ApresUnLancerOnAjouteLeNombreDeQuillesTombeesAuScore()
        {
            var bowling      = new Bowling();
            var currentScore = bowling.Score;

            bowling.Lance(6);
            Assert.AreEqual(currentScore + 6, bowling.Score);
        }
        public void ApresUnLancer0EtUnLancer10OnAUnSpare()
        {
            var bowling = new Bowling();

            bowling.Lance(0);
            bowling.Lance(10);
            Assert.AreEqual(Lancer.Spare, bowling.ResultatLancer);
        }
        public void ApresUnStrikeOnPasseALaFrameSuivante()
        {
            var bowling      = new Bowling();
            var currentFrame = bowling.Frame;

            bowling.Lance(10);
            Assert.AreEqual(currentFrame + 1, bowling.Frame);
        }
        public void LeSecondLancerEstNormalSIlResteDesQuilles()
        {
            var bowling = new Bowling();

            bowling.Lance(4);
            bowling.Lance(5);
            Assert.AreEqual(Lancer.Normal, bowling.ResultatLancer);
        }
        public void SiLeLancerDAvantEstUnStrikeOnCompte2FoisLeLancer()
        {
            var bowling = new Bowling();

            bowling.Lance(10);
            var currentScore = bowling.Score;

            bowling.Lance(7);
            Assert.AreEqual(currentScore + 7 * 2, bowling.Score);
        }
        public void SiLeLancerDAvantEstUnSpareOnCompte2FoisLeLancer()
        {
            var bowling = new Bowling();

            bowling.Lance(4);
            bowling.Lance(6);
            var currentScore = bowling.Score;

            bowling.Lance(3);
            Assert.AreEqual(currentScore + 3 * 2, bowling.Score);
        }
        public void SiLeLancerDAvantEstUnStrikeEtCeluiAvantUnStrikeOnCompte3FoisLeLancer()
        {
            var bowling = new Bowling();

            bowling.Lance(10);
            bowling.Lance(10);
            var currentScore = bowling.Score;

            bowling.Lance(6);
            Assert.AreEqual(currentScore + 6 * 3, bowling.Score);
        }
        public void ApresLaFrame10LaPartieEstFinie()
        {
            var bowling = new Bowling();

            foreach (var resultat in Enumerable.Repeat(1, 19))
            {
                bowling.Lance(resultat);
            }
            Assert.IsFalse(bowling.PartieFinie);
            bowling.Lance(1);
            Assert.IsTrue(bowling.PartieFinie);
        }
Beispiel #15
0
        public void WhenBowlingGutterBall_Return0()
        {
            var Bowling = new Bowling();

            for (var i = 1; i <= Bowling.Rounds; i++)
            {
                Bowling.Roll(0, 0);
            }

            var expected = 0;

            Assert.AreEqual(expected, Bowling.Score());
        }
Beispiel #16
0
        public void WhenBowlingGetScore_ReturnScore(int firstScore, int SecondScore, int exceptedScore)
        {
            var Bowling = new Bowling();

            for (var i = 1; i <= Bowling.Rounds; i++)
            {
                Bowling.Roll(firstScore, SecondScore);
            }

            var expected = exceptedScore;

            Assert.AreEqual(expected, Bowling.Score());
        }
        public void ApresUnSpareLaPartieEstFinieAuFrame10AvecUnLancerSupplementaire()
        {
            var bowling = new Bowling();

            foreach (var resultat in Enumerable.Repeat(1, 18))
            {
                bowling.Lance(resultat);
            }
            bowling.Lance(5);
            bowling.Lance(5);
            Assert.IsFalse(bowling.PartieFinie);
            bowling.Lance(1);
            Assert.IsTrue(bowling.PartieFinie);
        }
        public void ApresUnStrikePartieEstFinieAuBoutDe2LancersSupplementaires()
        {
            var bowling = new Bowling();

            foreach (var resultat in Enumerable.Repeat(1, 18))
            {
                bowling.Lance(resultat);
            }
            bowling.Lance(10);
            bowling.Lance(1);
            Assert.IsFalse(bowling.PartieFinie);
            bowling.Lance(1);
            Assert.IsTrue(bowling.PartieFinie);
        }
        public void SiDernierFrameEstUnStrikeApres2StrikeOnArrete()
        {
            var bowling = new Bowling();

            foreach (var resultat in Enumerable.Repeat(1, 18))
            {
                bowling.Lance(resultat);
            }
            bowling.Lance(10);
            bowling.Lance(10);
            Assert.IsFalse(bowling.PartieFinie);
            bowling.Lance(10);
            Assert.IsTrue(bowling.PartieFinie);
        }
Beispiel #20
0
        public void WhenBowlingGetStrike_ReturnScore()
        {
            var Bowling = new Bowling();

            Bowling.Roll(1, 0);  //1
            Bowling.Roll(10, 0); //0 -> 11 + 1 = 12
            Bowling.Roll(1, 0);  //13
            Bowling.Roll(1, 0);  //14
            Bowling.Roll(10, 0); //25
            Bowling.Roll(1, 0);  //26
            Bowling.Roll(1, 0);  //27
            Bowling.Roll(1, 0);  //28
            Bowling.Roll(1, 0);  //29
            Bowling.Roll(1, 0);  //30

            var expected = 30;

            Assert.AreEqual(expected, Bowling.Score());
        }
Beispiel #21
0
        public void test()
        {
            var Bowling = new Bowling();

            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1
            Bowling.Roll(9, 0); //1

            var expected = 90;

            Assert.AreEqual(expected, Bowling.Score());
        }
Beispiel #22
0
        public void WhenBowlingGetSpare_ReturnScore()
        {
            var Bowling = new Bowling();

            Bowling.Roll(1, 0); //1
            Bowling.Roll(1, 9); //0 -> 11 + 1 = 12
            Bowling.Roll(1, 0); //13
            Bowling.Roll(1, 0); //14
            Bowling.Roll(1, 0); //15
            Bowling.Roll(1, 0); //16
            Bowling.Roll(1, 0); //17
            Bowling.Roll(1, 0); //18
            Bowling.Roll(1, 0); //19
            Bowling.Roll(1, 0); //20

            var expected = 20;

            Assert.AreEqual(expected, Bowling.Score());
        }
Beispiel #23
0
        public void WhenBowling10RoundGetFirstStrike_ReturnScore()
        {
            var Bowling = new Bowling();

            Bowling.Roll(1, 0);  //1
            Bowling.Roll(10, 0); //0 -> 11 + 1 = 12
            Bowling.Roll(1, 0);  //13
            Bowling.Roll(1, 0);  //14
            Bowling.Roll(10, 0); //25
            Bowling.Roll(1, 0);  //26
            Bowling.Roll(1, 0);  //27
            Bowling.Roll(1, 0);  //28
            Bowling.Roll(1, 0);  //29

            Bowling.Roll(10, 0); //46
            Bowling.Roll(4, 3);

            var expected = 46;

            Assert.AreEqual(expected, Bowling.Score());
        }
Beispiel #24
0
        public void WhenBowling10RoundGetFirstSpare_ReturnScore()
        {
            var Bowling = new Bowling();

            Bowling.Roll(1, 0);  //1
            Bowling.Roll(10, 0); //0 -> 11 + 1 = 12
            Bowling.Roll(1, 0);  //13
            Bowling.Roll(1, 0);  //14
            Bowling.Roll(10, 0); //25
            Bowling.Roll(1, 0);  //26
            Bowling.Roll(1, 0);  //27
            Bowling.Roll(1, 0);  //28
            Bowling.Roll(1, 0);  //29

            Bowling.Roll(3, 7);  //43
            Bowling.Roll(4, 0);  //Sencond = -

            var expected = 43;

            Assert.AreEqual(expected, Bowling.Score());
        }
Beispiel #25
0
        public void WhenBowling10RoundGetSecondStrike_ReturnScore()
        {
            var Bowling = new Bowling();

            Bowling.Roll(1, 0);  //1
            Bowling.Roll(10, 0); //0 -> 11 + 1 = 12
            Bowling.Roll(1, 0);  //13
            Bowling.Roll(1, 0);  //14
            Bowling.Roll(10, 0); //25
            Bowling.Roll(1, 0);  //26
            Bowling.Roll(1, 0);  //27
            Bowling.Roll(1, 0);  //28
            Bowling.Roll(1, 0);  //29

            Bowling.Roll(10, 0); //49
            Bowling.Roll(10, 0); //
            Bowling.Roll(3, 0);  //Sencond = -

            var expected = 52;

            Assert.AreEqual(expected, Bowling.Score());
        }
        static void Main(string[] args)
        {
            var bowling = new Bowling();

            while (!bowling.PartieFinie)
            {
                try
                {
                    Console.WriteLine("Frame: {0}", bowling.Frame + 1);
                    Console.WriteLine("Score: {0}", bowling.Score);
                    Console.WriteLine("Lancer: {0}", bowling.LancerDansLaFrame);
                    Console.WriteLine("Quilles:{0}", bowling.Quilles);

                    Console.Write("Nombre de quilles tombees:");
                    bowling.Lance(int.Parse(Console.ReadLine()));
                    Console.WriteLine();
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatIncorrect");
                }
            }
            Console.WriteLine("Score Final:{0}", bowling.Score);
        }
Beispiel #27
0
        private void RollBall_Click(object sender, EventArgs e)
        {
            if (this.ballCounter > 20)
            {
                return;
            }

            int currentBallScore = this.ballCounter % 2 == 0 ? Bowling.ScoreBall() : Bowling.ScoreBall(this.numericScores[this.ballCounter - 1]);

            if (currentBallScore > 10)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (this.ballCounter < 18)
            {
                if (this.ballCounter % 2 == 0 && currentBallScore == 10)
                {
                    this.numericScores[this.ballCounter]     = 10;
                    this.printedScores[this.ballCounter]     = "X";
                    this.printedScores[this.ballCounter + 1] = "-";
                    this.ballCounter += 2;
                    this.DisplayScores();
                    return;
                }

                if (this.ballCounter % 2 != 0 && (this.numericScores[this.ballCounter - 1] + currentBallScore) == 10)
                {
                    this.numericScores[this.ballCounter] = currentBallScore;
                    this.printedScores[this.ballCounter] = "/";
                    this.ballCounter++;
                    this.DisplayScores();
                    return;
                }

                this.numericScores[this.ballCounter] = currentBallScore;
                this.printedScores[this.ballCounter] = currentBallScore.ToString();
                this.DisplayScores();
                this.ballCounter++;

                return;
            }

            if (this.ballCounter >= 18 && this.ballCounter < 20)
            {
                if (this.ballCounter != 18 || currentBallScore != 10)
                {
                    if (this.ballCounter == 19 && (this.numericScores[18] + currentBallScore) == 10 && this.numericScores[18] != 10)
                    {
                        this.numericScores[this.ballCounter] = currentBallScore;
                        this.printedScores[this.ballCounter] = "/";
                        this.ballCounter++;
                        this.DisplayScores();
                        return;
                    }

                    this.numericScores[this.ballCounter] = currentBallScore;
                    this.printedScores[this.ballCounter] = currentBallScore.ToString();
                    this.DisplayScores();
                    this.ballCounter++;
                }
                else
                {
                    this.numericScores[this.ballCounter] = 10;
                    this.printedScores[this.ballCounter] = "X";
                    this.ballCounter++;
                    this.DisplayScores();
                    return;
                }
            }

            if (this.ballCounter == 20 && (this.numericScores[18] + this.numericScores[19] >= 10))
            {
                this.numericScores[this.ballCounter] = currentBallScore;
                this.printedScores[this.ballCounter] = currentBallScore.ToString();
                this.DisplayScores();
                this.ballCounter++;
            }

            if (this.ballCounter == 20 && (this.numericScores[18] + this.numericScores[19] < 10))
            {
                this.Frame10Ball3.Text = @"-";
                this.ballCounter++;
                this.DisableButtons();
            }

            if (this.ballCounter > 20)
            {
                this.DisableButtons();
            }
        }
        public void AuPremierLancerOnEstALaFrame0()
        {
            var bowling = new Bowling();

            Assert.AreEqual(0, bowling.Frame);
        }
        public void AuPremierLancerLeScoreEstA0()
        {
            var bowling = new Bowling();

            Assert.AreEqual(0, bowling.Score);
        }
        public void PremierLancerPeutFaireTomberAuPlus10Quilles()
        {
            var bowling = new Bowling();

            Assert.AreEqual(10, bowling.Quilles);
        }