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
30 changes: 29 additions & 1 deletion 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,35 @@ let jobTypes = {
programmer: 'Any Ship!'
};

// Your code here
class CrewMember{
constructor(name,job,specialSkill){
this.name = name;
this.job = job;
this.specialSkill=specialSkill;
this.ship = null;
}
enterShip (myShip){
this.ship = myShip;
// assign new ship pointer to ship object in crew object
myShip.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.

// create cicular reference to crew member object in ship
}
}
class Ship{
constructor(name,type,ability){
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."
// need crew memember to perform any function of the mission
}
}


Choose a reason for hiding this comment

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

You should make a instance of the crewMember and the Ship,
then you should have the crewMember enter ship.


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