public static void SetUpGame(TestContext testContext)
        {
            Game1 = new Bowling.Game("My First Game");
            Game1.Throw(5).Spare()              // 1	10
            .Throw(0).Spare()                   // 2	22
            .Throw(2).Throw(4)                  // 3	28
            .Throw(1).Throw(0)                  // 4	29
            .Throw(4).Throw(1)                  // 5	34
            .Strike()                           // 6	46
            .Throw(0).Throw(2)                  // 7	48
            .Strike()                           // 8	63
            .Throw(2).Throw(3)                  // 9	68
            .Throw(2).Throw(3);                 // 10	73
            Game2 = new Bowling.Game("My Second Game");
            Game2.Throw(5).Spare()              // 1	10
            .Throw(0).Spare()                   // 2	30
            .Strike()                           // 3	54
            .Strike()                           // 4	69
            .Throw(4).Throw(1)                  // 5	74
            .Strike()                           // 6	86
            .Throw(0).Throw(2)                  // 7	88
            .Strike()                           // 8	103
            .Throw(2).Throw(3)                  // 9	108
            .Throw(2).Spare()                   // 10	128
            .Strike();

            ExpectedReturnGame1 = new List <int>()
            {
                10, 22, 28, 29, 34, 46, 48, 63, 68, 73
            };
            ExpectedReturnGame2 = new List <int>()
            {
                10, 30, 54, 69, 74, 86, 88, 103, 108, 128
            };
        }
Пример #2
0
        public void TestScore()
        {
            Game obj = new Game();

            obj.Roll(1);
            obj.Roll(4);

            obj.Roll(4);
            obj.Roll(5);

            obj.Roll(6);
            obj.Roll(4);

            obj.Roll(5);
            obj.Roll(5);

            obj.Roll(10);

            obj.Roll(0);
            obj.Roll(1);

            obj.Roll(7);
            obj.Roll(3);

            obj.Roll(6);
            obj.Roll(4);

            obj.Roll(10);
            obj.Roll(2);

            obj.Roll(8);
            obj.Roll(6);

            Assert.AreEqual(133, obj.Score());
        }
Пример #3
0
 public void FrameFourScoreTest()
 {
     var target = new Game(new[] {1, 4, 4, 5, 6, 4});
     target.Roll(5);
     target.Roll(5);
     target.Score().should_equal(44);
 }
Пример #4
0
        static void Main(string[] args)
        {
            Game game = new Game ();
            game.Start ();

            Console.ReadLine ();
        }
Пример #5
0
 public void FrameOneLessThanTenTest()
 {
     var target = new Game();
     target.Roll(1);
     target.Roll(4);
     target.Score().should_equal(5);
 }
Пример #6
0
 public void FrameThreeScoreTest()
 {
     var target = new Game(new[] { 1, 4, 4, 5 });
     target.Roll(6);
     target.Roll(4);
     target.Score().should_equal(24);
 }
Пример #7
0
        public void TooFewFrames()
        {
            var ValidGame = new Bowling.Game("My First Game");

            ValidGame.Throw(2);
            Assert.IsFalse(ValidGame.IsGameOver);
        }
Пример #8
0
 public void FrameTwoScoreTest()
 {
     var target = new Game(new[] { 1, 4 });
     target.Roll(4);
     target.Roll(5);
     target.Score().should_equal(14);
 }
Пример #9
0
        public void TooManyPinsWithTwoThrows()
        {
            var ValidGame = new Bowling.Game("My First Game");

            ValidGame.Throw(5).Spare()                  // 1  10
            .Throw(0).Spare()                           // 2 22
            .Throw(5).Throw(6);                         // 10 73
        }
Пример #10
0
        //Get values for all cells & organize it into the Game / Frame structure properly.
        private void RefreshFrames()
        {
            //Create an array of Frame objects representative of the current state of all input boxes.
            Frame[] _frames = new Frame[10];
            _frames[0] = new Frame(1, new int[] { frame1r1.IntValue, frame1r2.IntValue });
            _frames[1] = new Frame(2, new int[] { frame2r1.IntValue, frame2r2.IntValue });
            _frames[2] = new Frame(3, new int[] { frame3r1.IntValue, frame3r2.IntValue });
            _frames[3] = new Frame(4, new int[] { frame4r1.IntValue, frame4r2.IntValue });
            _frames[4] = new Frame(5, new int[] { frame5r1.IntValue, frame5r2.IntValue });
            _frames[5] = new Frame(6, new int[] { frame6r1.IntValue, frame6r2.IntValue });
            _frames[6] = new Frame(7, new int[] { frame7r1.IntValue, frame7r2.IntValue });
            _frames[7] = new Frame(8, new int[] { frame8r1.IntValue, frame8r2.IntValue });
            _frames[8] = new Frame(9, new int[] { frame9r1.IntValue, frame9r2.IntValue });
            _frames[9] = new Frame(10, new int[] { frame10r1.IntValue, frame10r2.IntValue, frame10r3.IntValue });

            //If this is the first update, instantiate the Game object for this window. If not, just update the frames in the pre-existing one.
            if (game == null) {
                game = new Game(_frames);
            } else {
                game.UpdateFrames(_frames);
            }

            //Set subtotal boxes (as long as the frame has been modified)
            int[] _subtotals = game.GetIncremTotals();
            if (frame1r1.Text != string.Empty) {
                frame1total.Text = _subtotals[0].ToString();
            }
            if (frame2r1.Text != string.Empty) {
                frame2total.Text = _subtotals[1].ToString();
            }
            if (frame3r1.Text != string.Empty) {
                frame3total.Text = _subtotals[2].ToString();
            }
            if (frame4r1.Text != string.Empty) {
                frame4total.Text = _subtotals[3].ToString();
            }
            if (frame5r1.Text != string.Empty) {
                frame5total.Text = _subtotals[4].ToString();
            }
            if (frame6r1.Text != string.Empty) {
                frame6total.Text = _subtotals[5].ToString();
            }
            if (frame7r1.Text != string.Empty) {
                frame7total.Text = _subtotals[6].ToString();
            }
            if (frame8r1.Text != string.Empty) {
                frame8total.Text = _subtotals[7].ToString();
            }
            if (frame9r1.Text != string.Empty) {
                frame9total.Text = _subtotals[8].ToString();
            }
            if (frame10r1.Text != string.Empty) {
                frame10total.Text = _subtotals[9].ToString();
            }

            //Set game total status
            gameTotal.Text = ("Game Total: " + game.GetTotal());
        }
Пример #11
0
 public int Check_many_pins(int[] pins)
 {
     var game = new Game();
     for (int i = 0; i < pins.Length; i++)
     {
         game.Roll(pins[i]);
     }
     return game.GetScore();
 }
Пример #12
0
        public void Check_all_zero()
        {
            var game = new Game();

            foreach (var spinstepPin in Enumerable.Range(1,20))
                game.Roll(0);

            Assert.AreEqual(0, game.GetScore());
        }
Пример #13
0
        static void Main(string[] args)
        {
            var g = new Game();

            g.Roll(2);
            Console.WriteLine($"Your score is {g.Score()}");

            //var xml = "<note class=\"test\"><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>";
        }
Пример #14
0
        public void ThrewTooMany()
        {
            var ValidGame = new Bowling.Game("My First Game");

            while (!ValidGame.IsGameOver)
            {
                ValidGame.Throw(2);
            }
            ValidGame.Throw(2);
        }
Пример #15
0
        public void GameIsOver()
        {
            var ValidGame = new Bowling.Game("My First Game");

            for (var i = 0; i < 10; i++)
            {
                ValidGame.Throw(0).Throw(2);
            }

            Assert.IsTrue(ValidGame.IsGameOver);
        }
Пример #16
0
 public static void SetUpGame(TestContext testContext)
 {
     ValidGame = new Bowling.Game("My First Game");
     while (!ValidGame.IsGameOver)
     {
         ValidGame.Strike();
     }
     ExpectedReturn = new List <int>()
     {
         30, 60, 90, 120, 150, 180, 210, 240, 270, 300
     };
 }
Пример #17
0
        public void TestRoll()
        {
            Game obj = new Game();

            Assert.AreEqual(-1, obj.Roll(-1));

            Assert.AreEqual(0, obj.Roll(0));
            Assert.AreEqual(0, obj.Roll(1));

            Assert.AreEqual(0, obj.Roll(10));
            Assert.AreEqual(-1, obj.Roll(11));
        }
Пример #18
0
        public static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Enter your rolls:");

                string rolls = Console.ReadLine();

                Game bowlingGame = new Game(rolls);

                Console.WriteLine("You scored: " + bowlingGame.TotalScore);
            }
        }
Пример #19
0
        public void TestSpares()
        {
            Game obj = new Game();

            obj.Roll(1);
            obj.Roll(4);

            obj.Roll(4);
            obj.Roll(5);

            obj.Roll(6);
            obj.Roll(4);

            obj.Roll(2);
            obj.Roll(4);

            Assert.AreEqual(2, obj.SpareValue(2));
        }
Пример #20
0
        static void Main(string[] args)
        {
            Game obj = new Game();
            int k;
            while (frames < 10)
            {
                Console.WriteLine("Enter the Score:");
                k = Convert.ToInt32(Console.ReadLine());
                obj.Roll(k);
            }

            Console.WriteLine("The Total Score of the Game: " + obj.Score());
            Console.ReadKey();
        }
Пример #21
0
 public void Check_zero_value()
 {
     var game = new Game();
     game.Roll(0);
     Assert.AreEqual(0, game.GetScore());
 }
Пример #22
0
 public void InitialScoreIsZeroTest()
 {
     var target = new Game();
     target.Score().should_equal(0);
 }
Пример #23
0
 public void InitializeGameTest()
 {
     var target = new Game(new [] {1, 4});
     target.Score().should_equal(5);
 }
Пример #24
0
 public void Chek_one_notLimit_value(int input)
 {
     var game = new Game();
     game.Roll(input);
     Assert.AreEqual(input,game.GetScore());
 }
Пример #25
0
        static void TestGames()
        {
            //Initialize a bunch of test games, from http://farm4.static.flickr.com/3326/3191334120_4b716b1d90.jpg (and a test perfect game to validate strike handling)
            int[][] test1 = {
                new int[] { 6, 1 },
                new int[] { 3, 4 },
                new int[] { 2, 8 },
                new int[] { 8, 2 },
                new int[] { 5, 0 },
                new int[] { 3, 0 },
                new int[] { 2, 2 },
                new int[] { 6, 2 },
                new int[] { 8, 0 },
                new int[] { 5, 1 }
            };

            int[][] test2 = {
                new int[] { 1, 8 },
                new int[] { 5, 0 },
                new int[] { 10, 0 },
                new int[] { 8, 0 },
                new int[] { 8, 0 },
                new int[] { 10, 0 },
                new int[] { 7, 2 },
                new int[] { 7, 1 },
                new int[] { 8, 2 },
                new int[] { 5, 0 }
            };

            int[][] test3 = {
                new int[] { 9, 1 },
                new int[] { 8, 2 },
                new int[] { 6, 0 },
                new int[] { 10, 0 },
                new int[] { 9, 1 },
                new int[] { 0, 8 },
                new int[] { 7, 2 },
                new int[] { 0, 10 },
                new int[] { 7, 3 },
                new int[] { 7, 2 }
            };

            int[][] test4 = {
                new int[] { 7, 2 },
                new int[] { 10, 0 },
                new int[] { 3, 6 },
                new int[] { 7, 3 },
                new int[] { 7, 2 },
                new int[] { 7, 3 },
                new int[] { 8, 0 },
                new int[] { 8, 1 },
                new int[] { 8, 2 },
                new int[] { 9, 0 }
            };

            int[][] test5 = {
                new int[] { 9, 0 },
                new int[] { 9, 0 },
                new int[] { 8, 0 },
                new int[] { 6, 0 },
                new int[] { 7, 1 },
                new int[] { 10, 0 },
                new int[] { 9, 1 },
                new int[] { 8, 0 },
                new int[] { 7, 1 },
                new int[] { 7, 2 }
            };

            int[][] testperfect = {
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 0 },
                new int[] { 10, 10, 10 }
            };

            //Stack up all the games and test!
            Game game1 = new Game(test1);
            Game game2 = new Game(test2);
            Game game3 = new Game(test3);
            Game game4 = new Game(test4);
            Game game5 = new Game(test5);
            Game gamePerfect = new Game(testperfect);
            System.Console.WriteLine("Game 1 total: " + game1.GetTotal());
            System.Console.WriteLine("Game 2 total: " + game2.GetTotal());
            System.Console.WriteLine("Game 3 total: " + game3.GetTotal());
            System.Console.WriteLine("Game 4 total: " + game4.GetTotal());
            System.Console.WriteLine("Game 5 total: " + game5.GetTotal());
            System.Console.WriteLine("Perfect game: " + gamePerfect.GetTotal());

            //Pause until you can see all the scores and then quit!
            System.Console.ReadKey();
        }
Пример #26
0
        public void TestStrike()
        {
            Game obj = new Game();

            obj.Roll(1);
            obj.Roll(4);

            obj.Roll(10);

            obj.Roll(4);
            obj.Roll(5);

            obj.Roll(4);
            obj.Roll(4);

            Assert.AreEqual(9, obj.strikeValue(1));
        }
Пример #27
0
        public void CalculateScore(string rolls, int score)
        {
            Game game = new Game(rolls);

            Assert.AreEqual(game.TotalScore, score);
        }
Пример #28
0
 public TenthFrame(int number, Game game)
     : base(number, game)
 {
 }
Пример #29
0
 public Frame(int number, Game game)
 {
     this.Number = number;
     this.game = game;
     Rolls = new List<int>();
 }
Пример #30
0
        //Reset form and game
        private void ResetFrames()
        {
            frame1r1.Text = string.Empty;
            frame1r2.Text = string.Empty;
            frame2r1.Text = string.Empty;
            frame2r2.Text = string.Empty;
            frame3r1.Text = string.Empty;
            frame3r2.Text = string.Empty;
            frame4r1.Text = string.Empty;
            frame4r2.Text = string.Empty;
            frame5r1.Text = string.Empty;
            frame5r2.Text = string.Empty;
            frame6r1.Text = string.Empty;
            frame6r2.Text = string.Empty;
            frame7r1.Text = string.Empty;
            frame7r2.Text = string.Empty;
            frame8r1.Text = string.Empty;
            frame8r2.Text = string.Empty;
            frame9r1.Text = string.Empty;
            frame9r2.Text = string.Empty;
            frame10r1.Text = string.Empty;
            frame10r2.Text = string.Empty;
            frame10r3.Text = string.Empty;

            game = null;

            RefreshFrames();
        }