From cee4caf37a83a07122afd6780abba7a6c6f23edf Mon Sep 17 00:00:00 2001 From: Craig Copeland Date: Tue, 8 Aug 2017 20:41:53 -0500 Subject: [PATCH 1/2] Travel to Mars Program - initial push. Whiteboard and skeleton code. --- 05week/spaceTravelToMars.js | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/05week/spaceTravelToMars.js b/05week/spaceTravelToMars.js index ce258a382..191b4defd 100644 --- a/05week/spaceTravelToMars.js +++ b/05week/spaceTravelToMars.js @@ -9,7 +9,44 @@ let jobTypes = { programmer: 'Any Ship!' }; -// Your code here +/**************************WHITE BOARD NOTES ************************* +// CrewMember +// 1) should have a name, a job, a specialSkill and ship upon instantiation +// 2) can enter a ship +// +// Ship +// 3) should have a name, a type, an ability and an empty crew upon instantiation +// 4) can return a mission statement correctly +// +// 1) CrewMember should have a name, a job, a specialSkill and ship upon instantiation: +// +// 2) CrewMember can enter a ship: +// +// 3) Ship should have a name, a type, an ability and an empty crew upon instantiation: +// +// 4) Ship can return a mission statement correctly: +*******************************************************************************/ + +class CrewMember { + constructor(name, job, specialSkill, ship) { + this.name = name; + this.job = job; + this.specialSkill = specialSkill; + this.ship = null; + } + enterShip(leShip) { + leShip.crew.push(this.name); + } +} + +class Ship { + constructor(name, type, ability) { + this.name = name; + this.type = type; + this.ability = ability; + this.crew = []; + } +} //tests if (typeof describe === 'function'){ From 3f0ee05323424be542bfdf55d2880cb560f775e1 Mon Sep 17 00:00:00 2001 From: Craig Copeland Date: Tue, 8 Aug 2017 22:01:48 -0500 Subject: [PATCH 2/2] Travel to Mars functionality completed --- 05week/spaceTravelToMars.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/05week/spaceTravelToMars.js b/05week/spaceTravelToMars.js index 191b4defd..ff5087e9a 100644 --- a/05week/spaceTravelToMars.js +++ b/05week/spaceTravelToMars.js @@ -35,7 +35,9 @@ class CrewMember { this.ship = null; } enterShip(leShip) { - leShip.crew.push(this.name); + console.log(this.name); + leShip.crew.push(this); + this.ship = leShip; } } @@ -46,6 +48,13 @@ class Ship { this.ability = ability; this.crew = []; } + missionStatement() { + if (this.crew.length) { + return this.ability; + } else { + return "Can't perform a mission yet."; + } + } } //tests