Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Function originally posted at https://piazza.com/class/isjawvyo9lc1rl?cid=160 by Akhil Nistala
- *
- * Inputs: i, the number of times you want to iterate a function; f, the function you wish to execute i times.
- * Outputs: executes function f i times, no return value.
- *
- */
- var times = function (i, f) {
- if (i === 0) return;
- f();
- times (i-1, f);
- };
- /*
- * Board class
- *
- */
- var Board = function(){
- const rows = 50;
- const cols = 50;
- var that = Object.create(Board.prototype);
- var board_arr = [];
- var i = 0;
- times(rows, function(){
- var row = [];
- var j = 0;
- times(cols, function(){
- row.push(false);
- j = j+1;
- });
- board_arr.push(row);
- i = i+1;
- })
- that.get_board_arr = function(){
- return board_arr;
- }
- that.get_rows = function(){
- return rows;
- }
- that.get_cols = function(){
- return cols;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement