Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions 01week/helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

console.log("Hello World!");
101 changes: 101 additions & 0 deletions 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,107 @@ let jobTypes = {
};

// Your code here
class CrewMember {
constructor(name, job, specialSkill,ship) {
this.name = name;
this.job = job;
this.specialSkill = specialSkill;
this.ship = null;
}

//this method should add THIS crew member to the ship being passed in
//note: an entire ship instance is passed in, not just the name
//note: the entire crew member is added to the ships array of crew
description (){
if(this.ship == null) {
return `${this.name} is a ${this.job} and isn't assign too a ship`;
} else {
return `${this.name} is a ${this.job} and is assign to ${this.ship}`;
}


}

enterShip(currentShip) {
this.ship = currentShip;
currentShip.crew.push(this);

//crewMember1.assignedShip = mav
//mav.crew.push(crewMember1);

}
}








class Ship {
constructor(name, type, ability) {
this.name = name;
this.type = type;
this.ability = ability;
this.crew = [];
}
// this method should return the ship's ability if there is a crew member
// whose job matches up with the ship's type

missionStatement() {
// if the length of the crew is equal to zero
if(this.crew.length == 0) {
//then return cannot perfrom
return "Can't perform a mission yet."
//now need to compare job vs ability
} else if (this.job == this.ability){
Copy link

Choose a reason for hiding this comment

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

need to compare the ship's type with the crew member's abilities

//need to return it ability
return "this thing is working"

}
}
}
//created first crew member
let rick = new CrewMember('Rick Martinez', 'pilot', 'Ascend into low orbit');
//console.log(crewMember1);
//created second crew member
let lewis = new CrewMember('Commander Lewis', 'commander', 'geology');
//console.log(crewMember2)
//created third crew member
let chris = new CrewMember('Chris Trevino', 'programmer', 'geology');
//created fourth crew member
let hitzel = new CrewMember('Hitzel Betts', 'mechanic', 'biology');

// ship one was created
let mav = new Ship('Mars Ascent Vehicle', 'MAV', 'Ascend into low orbit');
//console.log(mav);
//ship two was created
let hermes = new Ship('Hermes', 'Main Ship', 'Interplanetary Space Travel');
//console.log(hermes);
// console logged the input below to make sure mission statement works
// put crew members into ship
rick.enterShip(mav)
lewis.enterShip(hermes)
chris.enterShip(mav)
//console.log(mav.missionStatement());

//now need to test PUSH for adding a crew member to ship
//mav.crew.push(crewMember1);
// Testing the output with console log
console.log(mav.missionStatement());
console.log(hermes.missionStatement());
// Putting crewMember1 into MAV
//crewMember1.assignedShip = mav
// wanted to test the get in ship method
//console.log(crewMember1.description());
// shows that crew member one isn't assigned to a ship..... yet
//console.log(rick.description());
//console.log(mav);





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