From 4b6e78c8089df7af026156cdc0084e6f1e3c327d Mon Sep 17 00:00:00 2001 From: Christopher Willis Date: Thu, 8 Nov 2018 15:01:18 -0600 Subject: [PATCH 1/2] Major componates finished --- 05week/spaceTravelToMars.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/05week/spaceTravelToMars.js b/05week/spaceTravelToMars.js index ce258a382..1e46a17f7 100644 --- a/05week/spaceTravelToMars.js +++ b/05week/spaceTravelToMars.js @@ -9,7 +9,34 @@ 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; + this.ship.crew.push(this) + console.log(this.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." + + } +} + + //tests if (typeof describe === 'function'){ From efb2cc1a94e7468842bec84e258b03850e11c618 Mon Sep 17 00:00:00 2001 From: Christopher Willis Date: Thu, 8 Nov 2018 15:19:38 -0600 Subject: [PATCH 2/2] cleaned up code and added minor comments --- 05week/spaceTravelToMars.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/05week/spaceTravelToMars.js b/05week/spaceTravelToMars.js index 1e46a17f7..7ce007e4b 100644 --- a/05week/spaceTravelToMars.js +++ b/05week/spaceTravelToMars.js @@ -18,8 +18,9 @@ class CrewMember{ } enterShip (myShip){ this.ship = myShip; - this.ship.crew.push(this) - console.log(this.ship) + // assign new ship pointer to ship object in crew object + myShip.crew.push(this) + // create cicular reference to crew member object in ship } } class Ship{ @@ -32,7 +33,7 @@ class Ship{ 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 } }