diff --git a/04week/functional-javascript.js b/04week/functional-javascript.js new file mode 100644 index 000000000..f74978fa6 --- /dev/null +++ b/04week/functional-javascript.js @@ -0,0 +1,19 @@ +'use strict' + +//HELLO WORLD +// function upperCaser(input) { +// return input.toUpperCase(); +// } +// console.log(upperCaser("Hello World!")); + +// module.exports = function(input) { +// return input.toUpperCase() +// } + +//HIGHER ORDER +function repeat(operation, num) { + operation = addTwo(num); +} + + // Do not remove the line below + module.exports = repeat diff --git a/05week/checkers.js b/05week/checkers.js index 8f33a089c..80e816194 100644 --- a/05week/checkers.js +++ b/05week/checkers.js @@ -7,8 +7,8 @@ const rl = readline.createInterface({ output: process.stdout }); - function Checker() { + this.color = color; // Your code here } @@ -51,17 +51,45 @@ function Board() { } console.log(string); }; + // Your code here + this.checkers = []; + var whitePositions = [ + [0, 1], [0, 3], [0, 5], [0, 7], + [1, 0], [1, 2], [1, 4], [1, 6], + [2, 1], [2, 3], [2, 5], [2, 7] + ]; + var blackPositions = [ + [5, 0], [5, 2], [5, 4], [5, 6], + [6, 1], [6, 3], [6, 5], [6, 7], + [7, 0], [7, 2], [7, 4], [7, 6] + ]; + + for(let i = 0; i<11; i++){ + this.checkers.push(new Checker()) + } // Your code here } -function Game() { +// var arr = []; +// this.checkers = arr; +// for(let i = 0; i<24; i++){ +// arr.push(new Checker()) +// } +}; +function Game() { this.board = new Board(); this.start = function() { this.board.createGrid(); // Your code here - }; + } + this.moveChecker = function(param1, param2) { + var from = param1.toString().split(""); + var to = param2.toString().split(""); + this.board.grid[to[0]][to[1]] = this.board.grid[from[0]][from[1]]; + this.board.grid[from[0]][from[1]] = null; +} } function getPrompt() { @@ -90,6 +118,7 @@ if (typeof describe === 'function') { }); }); + describe('Game.moveChecker()', function () { it('should move a checker', function () { assert(!game.board.grid[4][1]); diff --git a/05week/spaceTravelToMars.js b/05week/spaceTravelToMars.js index ce258a382..eb023f1ef 100644 --- a/05week/spaceTravelToMars.js +++ b/05week/spaceTravelToMars.js @@ -10,6 +10,43 @@ let jobTypes = { }; // Your code here +class CrewMember { + constructor(name, job, specialSkill){ + this.name = name; + this.job = job; + this.specialSkill = specialSkill; + this.ship = null; + }; + + enterShip(ship){ + this.ship = ship; + this.ship.crew.push(this) + console.log(this) + } +}; + +class Ship{ + constructor(name, type, ability){ + this.name = name; + this.type = type; + this.ability = ability; + this.crew = []; + }; + + missionStatement(){ + //if the ship has a pilot, it can ascend into low orbit + if (this.crew.length > 0) { + return this.ability; + } else { + return "Can't perform a mission yet."; + } + } +}; + +// }; + + + //tests if (typeof describe === 'function'){