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
194 changes: 194 additions & 0 deletions 05week/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions 05week/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"scripts": {
"test": "mocha"
},
"devDependencies": {
"mocha": "^5.2.0"
}
}
49 changes: 41 additions & 8 deletions 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,39 @@

let assert = require('assert');

let jobTypes = {
pilot: 'MAV',
mechanic: 'Repair Ship',
commander: 'Main Ship',
programmer: 'Any Ship!'
};
//Crew Constructor
let CrewMember = function(name, job, specialSkill){
this.name = name,
this.job = job,
this.specialSkill = specialSkill,
this.ship
}

//Ship Constructor
let Ship = function(name, type, ability){
this.name = name,
this.type = type,
this.ability = ability,
this.crew = []
}

// Your code here
//This connects Ship to a crew
CrewMember.prototype.enterShip = function(ship){
//establish CrewMember.ship value
this.ship = ship;

//establish Ship.crew value
ship.crew = [this];
}

//Checks to see if a crew as been assigned
Ship.prototype.missionStatement = function(){
if(this.crew.length === 0 ){
return "Can't perform a mission yet.";
}else{
return this.ability;
}
}

//tests
if (typeof describe === 'function'){
Expand All @@ -27,8 +52,8 @@ if (typeof describe === 'function'){
let crewMember1 = new CrewMember('Rick Martinez', 'pilot', 'chemistry');
crewMember1.enterShip(mav);
assert.equal(crewMember1.ship, mav);
assert.equal(mav.crew.length, 1);
assert.equal(mav.crew[0], crewMember1);
assert.equal(mav.crew.length, 1);
});
});

Expand Down Expand Up @@ -57,3 +82,11 @@ if (typeof describe === 'function'){
});
});
}


// let jobTypes = {
// pilot: 'MAV',
// mechanic: 'Repair Ship',
// commander: 'Main Ship',
// programmer: 'Any Ship!'
// };
Loading