Skip to content
Open
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
41 changes: 41 additions & 0 deletions 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,47 @@ let jobTypes = {
};

// Your code here
class CrewMember {
constructor(name, job, specialSkill){
this.name = name;
this.job = job;
this.specialSkill = specialSkill;
this.crewMember = null;
}

enterShip(ship) {
this.ship = ship;
ship.crew.push(this);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your putting the entire object in the ship crew.

}
}

const crewMember1 = new CrewMember("Rick Martinez", "pilot", "chemistry");
const crewMember2 = new CrewMember("Commander Lewis", "commander", "geology");


class Ship {
constructor(name, type, ability) {
this.name = name;
this.type = type;
this.ability = ability;
this.crew = [];
}

missionStatement() {
if (this.crew.length) {
return this.ability;
}
else
return "Can't perform a mission yet.";
}
}

const mav = new Ship("Mars Ascent Vehicle", "MAV", "Ascend into low orbit");
const hermes = new Ship("Hermes", "Main Ship", "Interplanetary Space Travel");


crewMember1.enterShip(mav);
crewMember2.enterShip(hermes);

//tests
if (typeof describe === 'function'){
Expand Down