Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /*
  2. * Function originally posted at https://piazza.com/class/isjawvyo9lc1rl?cid=160 by Akhil Nistala
  3. *
  4. * Inputs: i, the number of times you want to iterate a function; f, the function you wish to execute i times.
  5. * Outputs: executes function f i times, no return value.
  6. *
  7. */
  8. var times = function (i, f) {
  9. if (i === 0) return;
  10. f();
  11. times (i-1, f);
  12. };
  13.  
  14. /*
  15. * Board class
  16. *
  17. */
  18. var Board = function(){
  19. const rows = 50;
  20. const cols = 50;
  21. var that = Object.create(Board.prototype);
  22. var board_arr = [];
  23.  
  24. var i = 0;
  25. times(rows, function(){
  26. var row = [];
  27. var j = 0;
  28. times(cols, function(){
  29. row.push(false);
  30. j = j+1;
  31. });
  32. board_arr.push(row);
  33. i = i+1;
  34. })
  35.  
  36.  
  37.  
  38. that.get_board_arr = function(){
  39. return board_arr;
  40. }
  41.  
  42. that.get_rows = function(){
  43. return rows;
  44. }
  45.  
  46. that.get_cols = function(){
  47. return cols;
  48. }
  49.  
  50. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement