diff --git a/05week/spaceTravelToMars.js b/05week/spaceTravelToMars.js index ce258a382..ff68d5368 100644 --- a/05week/spaceTravelToMars.js +++ b/05week/spaceTravelToMars.js @@ -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?? + 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'){