Advertisement
Guest User

Bingo Test Cases

a guest
Apr 21st, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //tests draw function with X's and O's
  2. //tests random boards for each win occurance
  3. var myGame = MiniBingo();
  4.  
  5.  
  6. i=0;
  7.  
  8. while(myGame.IsGameOver() != true){
  9.  
  10.   var randomNum = Math.floor(Math.random() * 9) + 1
  11.  
  12.  
  13.   if (i%2 == 0 && myGame.IsValidMove(randomNum) == true){
  14.     //myGame.MakeMove('O', randomNum);
  15.     i++;
  16.   }
  17.   else if (myGame.IsValidMove(randomNum)){
  18.     myGame.MakeMove('X', randomNum);
  19.     i++;
  20.   }
  21. }
  22.  
  23.  
  24.  
  25. console.log("A valid Bingo Has Occured: "  + myGame.IsWon('X'));
  26.  
  27. if (myGame.IsWonDiagonal('X') === true)
  28.   console.log("Bingo Diagonally.");
  29. else if (myGame.IsWonHorizontal('X') === true)
  30.   console.log("Bingo Horizontally.");
  31. else if (myGame.IsWonVertical('X') === true)
  32.   console.log("Bingo Vertically.")
  33. else if (myGame.IsWonCorners('X') === true)
  34.   console.log("Bingo Corners.")
  35. else if (myGame.IsWonPostageStamp('X') === true)
  36.   console.log("Bingo Postage Stamp.")
  37.  
  38. myGame.PrintBoard('draw');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement