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 }; }
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()); }
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); }
static void Main(string[] args) { Game game = new Game (); game.Start (); Console.ReadLine (); }
public void FrameOneLessThanTenTest() { var target = new Game(); target.Roll(1); target.Roll(4); target.Score().should_equal(5); }
public void FrameThreeScoreTest() { var target = new Game(new[] { 1, 4, 4, 5 }); target.Roll(6); target.Roll(4); target.Score().should_equal(24); }
public void TooFewFrames() { var ValidGame = new Bowling.Game("My First Game"); ValidGame.Throw(2); Assert.IsFalse(ValidGame.IsGameOver); }
public void FrameTwoScoreTest() { var target = new Game(new[] { 1, 4 }); target.Roll(4); target.Roll(5); target.Score().should_equal(14); }
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 }
//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()); }
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(); }
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()); }
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>"; }
public void ThrewTooMany() { var ValidGame = new Bowling.Game("My First Game"); while (!ValidGame.IsGameOver) { ValidGame.Throw(2); } ValidGame.Throw(2); }
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); }
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 }; }
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)); }
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); } }
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)); }
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(); }
public void Check_zero_value() { var game = new Game(); game.Roll(0); Assert.AreEqual(0, game.GetScore()); }
public void InitialScoreIsZeroTest() { var target = new Game(); target.Score().should_equal(0); }
public void InitializeGameTest() { var target = new Game(new [] {1, 4}); target.Score().should_equal(5); }
public void Chek_one_notLimit_value(int input) { var game = new Game(); game.Roll(input); Assert.AreEqual(input,game.GetScore()); }
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(); }
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)); }
public void CalculateScore(string rolls, int score) { Game game = new Game(rolls); Assert.AreEqual(game.TotalScore, score); }
public TenthFrame(int number, Game game) : base(number, game) { }
public Frame(int number, Game game) { this.Number = number; this.game = game; Rolls = new List<int>(); }
//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(); }