Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions 04week/functional-javascript.js
Original file line number Diff line number Diff line change
@@ -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
35 changes: 32 additions & 3 deletions 05week/checkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const rl = readline.createInterface({
output: process.stdout
});


function Checker() {
this.color = color;
// Your code here
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -90,6 +118,7 @@ if (typeof describe === 'function') {
});
});


describe('Game.moveChecker()', function () {
it('should move a checker', function () {
assert(!game.board.grid[4][1]);
Expand Down
37 changes: 37 additions & 0 deletions 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'){
Expand Down