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

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

// printOutName(){
// console.log(this.name)
// }

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.

You're pushing the entire class into the crew array

}

// assignToGenere(ship.emptyCrew){
// this.ship.emptyCrew = CrewMember.ship;
// ship.emptyCrew.push(this)
// }

};

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

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

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

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

Choose a reason for hiding this comment

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

You should have the crewMemeber enter the ship.

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