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
49 changes: 48 additions & 1 deletion 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,55 @@ let jobTypes = {
commander: 'Main Ship',
programmer: 'Any Ship!'
};
// need tp craete a Crewmember class with name, job, specialSkill, ship to == null
class CrewMember {
constructor(name, job, specialSkill){
this.name = name;
this.job = job;
this.specialSkill = specialSkill;
this.ship = null;
}

enterShip(ship){
//Yousif literally gave us this answer word for word thank you.
this.ship = ship;
ship.crew.push(this);
}
}
//create a ship class with a name, type and ability as well as a empty crew.
class Ship {
constructor(name, type, ability){
this.name = name;
this.type = type;
this.ability = ability;
this.crew = [];

}

// Your code here
missionStatement(){
//if crew. length == 0 it must return it cannot perform mission
if( this.crew.length == 0){
return "Can't perform a mission yet";
//if the crew is greater than 0 is will return the ships abillity.
} else {
//Im guessing this is the part that is broken in the code. not sure why??
Copy link

Choose a reason for hiding this comment

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

looks right to me, so not sure what you mean by broken?

return this.ability;
}

}
}
//need to create a ship for mav as well as hermes
let mav = new Ship('Mars Ascent Vehicle', 'MAV', 'Ascend into low orbit');
let hermes = new Ship('Hermes', 'Main Ship', 'Interplanetary Space Travel');
//need to create two crewmembers
let crewMember1 = new CrewMember('Rick Martinez', 'pilot', 'chemistry');
let crewMember2 = new CrewMember('Commander Lewis', 'commander', 'geology');
// utilizing the entership()method for both crew members into different ships
crewMember1.enterShip(mav);
crewMember2.enterShip(hermes);
//making sure the entership() method was successful
console.log(mav);
console.log(hermes);

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