예제 #1
0
        public void Can_Not_Roll_More_Than_Ten_In_Two_Rolls()
        {
            Bowling bowling = new Bowling();

            bowling.Roll(6);
            bowling.Roll(5);
        }
예제 #2
0
 public void Roll_Cant_Knock_Down_MoreThan_Ten(int pins)
 {
     Bowling bowling = new Bowling();
     int score = bowling.Roll(pins);
     int maxResult = 10;
     Assert.Equal(maxResult, score);
 }
예제 #3
0
        public void Roll_Set_The_Number_Of_Pins_Knocked_Down(int pins)
        {
            Bowling bowling = new Bowling();
            int     score   = bowling.Roll(pins);

            Assert.Equal(score, pins);
        }
예제 #4
0
        public void Roll_Cant_Knock_Down_MoreThan_Ten(int pins)
        {
            Bowling bowling   = new Bowling();
            int     score     = bowling.Roll(pins);
            int     maxResult = 10;

            Assert.Equal(maxResult, score);
        }
예제 #5
0
        public void Roll_Added_To_Score(int rollamount)
        {
            Bowling bowling = new Bowling();

            bowling.Roll(rollamount);

            Assert.That(bowling.Score, Is.EqualTo(rollamount));
        }
예제 #6
0
        public void Frame_Scores_Updated_with_Score_after_first_roll()
        {
            Bowling bowling = new Bowling();

            bowling.Roll(7);

            Assert.That(bowling.FrameScores, Is.EqualTo(new [] { 7 }));
        }
예제 #7
0
        public void Missing_Pins_Adds_No_Score()
        {
            Bowling bowling = new Bowling();

            bowling.Roll(0);

            Assert.That(bowling.Score, Is.EqualTo(0));
        }
예제 #8
0
        public void Multiple_Rolls_Added_To_Score()
        {
            Bowling bowling = new Bowling();

            bowling.Roll(5);
            bowling.Roll(5);

            Assert.That(bowling.Score, Is.EqualTo(10));
        }
예제 #9
0
 public void Roll_Can_Try_Up_To_Two_Times_Each_Square(int pins)
 {
     Bowling bowling = new Bowling();
     int score = bowling.Roll(pins);
     score += bowling.Roll(pins);
     score += bowling.Roll(pins);
     int tries = bowling.Tryies;
     Assert.Equal(2, tries);
 }
        static void Main(string[] args)
        {
            var inputArray = new int[] { 1, 4, 4, 5, 6, 4, 5, 5, 10, 0, 0, 1, 7, 3, 6, 4, 10, 0, 2, 8, 6 };
            //var inputArray = new int[]{10,0,10,0,10,0,10,0,10,0,10,0,10,0,10,0,10,0,10,10,10};

            var scoreCalculator = new Bowling();

            Console.WriteLine(scoreCalculator.CalcScore(inputArray));
        }
예제 #11
0
        public void Frame_Scores_Updated_with_Score_After_Two_Rolls()
        {
            var bowling = new Bowling();

            bowling.Roll(6);
            bowling.Roll(3);

            Assert.That(bowling.FrameScores, Is.EqualTo(new [] { 9 }));
        }
예제 #12
0
        public void Can_not_roll_more_than_ten_in_second_frame()
        {
            var bowling = new Bowling();

            bowling.Roll(6);
            bowling.Roll(3);
            bowling.Roll(9);
            bowling.Roll(3);
        }
예제 #13
0
        public void Frame_Scores_Updated_After_Strike_In_First_Roll()
        {
            var bowling = new Bowling();

            bowling.Roll(10);
            bowling.Roll(4);

            Assert.That(bowling.FrameScores, Is.EqualTo(new[] { 10, 4 }), "Frame score error");
            Assert.That(bowling.Score, Is.EqualTo(14), "Score error");
        }
예제 #14
0
        public void Roll_Can_Try_Up_To_Two_Times_Each_Square(int pins)
        {
            Bowling bowling = new Bowling();
            int     score   = bowling.Roll(pins);

            score += bowling.Roll(pins);
            score += bowling.Roll(pins);
            int tries = bowling.Tryies;

            Assert.Equal(2, tries);
        }
예제 #15
0
        public void Frame_Scores_and_score_Updated_with_score_after_three_rolls()
        {
            var bowling = new Bowling();

            bowling.Roll(6);
            bowling.Roll(3);
            bowling.Roll(2);

            Assert.That(bowling.FrameScores, Is.EqualTo(new[] { 9, 2 }), "Frame score error");
            Assert.That(bowling.Score, Is.EqualTo(11), "Score error");
        }
예제 #16
0
        public void Strike_with_wasted_next_frame_gets_no_Bonus()
        {
            var bowling = new Bowling();

            bowling.Roll(10);
            bowling.Roll(0);
            bowling.Roll(0);

            Assert.That(bowling.FrameScores, Is.EqualTo(new[] { 10, 0 }), "Frame score error");
            Assert.That(bowling.Score, Is.EqualTo(10), "Score error");
        }
예제 #17
0
        public void Strike_adds_subsequent_frame_score()
        {
            var bowling = new Bowling();

            bowling.Roll(10);
            bowling.Roll(2);
            bowling.Roll(5);

            Assert.That(bowling.FrameScores, Is.EqualTo(new[] { 17, 7 }), "Frame score error");
            Assert.That(bowling.Score, Is.EqualTo(24), "Score error");
        }
예제 #18
0
        static void Main(string[] args)
        {
            Bowling bowling = new Bowling();
            Random  rdm     = new Random();

            Console.WriteLine($"¡Bienvenido a Bowling Game!.");
            for (int i = 0; i < bowling.Turnos.Length;)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine($"Presiona Enter para realizar una tirada de pinos.");
                if (i >= 10)
                {
                    if (!bowling.Turnos[i - 1].esSpare && !bowling.Turnos[i - 1].esStrike)
                    {
                        break;
                    }
                }
                string Tecla = Console.ReadKey().Key.ToString();
                if (Tecla == "Enter")
                {
                    int pinosTiradosAleatorio = rdm.Next(0, 11);
                    bowling.RealizarTirada(pinosTiradosAleatorio);

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"Tiraste " + pinosTiradosAleatorio + " pinos !");

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"Tu puntaje Actual es: {bowling.PuntuacionActual}");

                    i = bowling.TurnoActual;
                    int turnosRestantes = 10 - i;

                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine($"Te quedan " + turnosRestantes + " turnos!");
                }
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine($"¡Juego terminado!");

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine($"Tu puntaje Final es: {bowling.PuntuacionActual}");
            Console.ReadLine();//Esperar input de usuario para cerrar el programa
        }
예제 #19
0
        public void Can_not_roll_more_than_10()
        {
            Bowling bowling = new Bowling();

            bowling.Roll(11);
        }
예제 #20
0
        public void Can_Retrieve_Frame_Scores()
        {
            Bowling bowling = new Bowling();

            Assert.That(bowling.FrameScores, Is.Empty);
        }
예제 #21
0
 public void Roll_Set_The_Number_Of_Pins_Knocked_Down(int pins)
 {
     Bowling bowling = new Bowling();
     int score = bowling.Roll(pins);
     Assert.Equal(score, pins);
 }