From 5f41a1733000014854948619de1824d1f46509a3 Mon Sep 17 00:00:00 2001 From: Renata Estes Date: Thu, 10 Aug 2017 22:22:14 -0500 Subject: [PATCH 1/3] oop --- 05week/spaceTravelToMars.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) 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'){ From 13401e39a02274b31563b0408baa1b6a12737785 Mon Sep 17 00:00:00 2001 From: Renata Estes Date: Tue, 15 Aug 2017 18:33:51 -0500 Subject: [PATCH 2/3] checkers --- 04week/functional-javascript.js | 19 +++++++++++++++++++ 05week/checkers.js | 19 +++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 04week/functional-javascript.js 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..26080323d 100644 --- a/05week/checkers.js +++ b/05week/checkers.js @@ -7,8 +7,8 @@ const rl = readline.createInterface({ output: process.stdout }); - function Checker() { + // Your code here } @@ -51,17 +51,27 @@ function Board() { } console.log(string); }; - // Your code here + var arr = []; + this.checkers = arr; + for(let i = 0; i<24; i++){ + arr.push(new Checker()) } -function Game() { +}; +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 +100,7 @@ if (typeof describe === 'function') { }); }); + describe('Game.moveChecker()', function () { it('should move a checker', function () { assert(!game.board.grid[4][1]); From d04ee52ff8dc229c52271fb7dccd9a5ace4e18b3 Mon Sep 17 00:00:00 2001 From: Renata Estes Date: Thu, 17 Aug 2017 18:39:01 -0500 Subject: [PATCH 3/3] commit --- 05week/checkers.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/05week/checkers.js b/05week/checkers.js index 26080323d..80e816194 100644 --- a/05week/checkers.js +++ b/05week/checkers.js @@ -8,7 +8,7 @@ const rl = readline.createInterface({ }); function Checker() { - + this.color = color; // Your code here } @@ -52,11 +52,29 @@ function Board() { console.log(string); }; // Your code here - var arr = []; - this.checkers = arr; - for(let i = 0; i<24; i++){ - arr.push(new Checker()) + 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 } +// var arr = []; +// this.checkers = arr; +// for(let i = 0; i<24; i++){ +// arr.push(new Checker()) +// } }; function Game() {