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 .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
149 changes: 149 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,150 @@
// CODE here for your Lambda Classes



class Person{
constructor(attributes){
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
}
speak(){
return `Hello my name is ${this.name}, I am form ${this.location}.`;
}
}

class Instructor extends Person{
constructor(instructorAttributes){
super(instructorAttributes);
this.specialty = instructorAttributes.specialty;
this.favLanguage = instructorAttributes.favLanguage;
this.catchPhrase = instructorAttributes.catchPhrase;
}
demo(subject){
return `today we are learning about ${subject}`;
}
grade(student,subject){
return `${student.name} receives a perfect sore on ${subject}`;
}
}

class Student extends Person{
constructor(studentAttributes){
super(studentAttributes);
this.previousBackground = studentAttributes.previousBackground;
this.className = studentAttributes.className;
this.favSubjects = studentAttributes.favSubjects;
}
listsSubjects(){
let tempString = '';
this.favSubjects.forEach( (item ) => {tempString += `${item} `});
return tempString;
}
PRAssignment(subject){
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject){
return `${this.name} has begun sprint challenge on ${subject}`;
}
}

class ProjectManager extends Person{
constructor(projectmanagerAttributes){
super(projectmanagerAttributes);
this.gradeClassname = projectmanagerAttributes.gradeClassname;
this.favInstructor = projectmanagerAttributes.favInstructor;
}
standUp(channel){
return `${this.name} announces to ${channel}, @channel standy times!`;
}
debugsCode(studentObj,subject){
return `${this.name} debugs ${studentObj.name}'s code on ${subject}`;

}
}
/////////////////////////////// /
// // /
// End of Class Constructors // |===========
// // \
/////////////////////////////// \


// Instructors///////////////////////////////////////////////////

const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});
const instructorTwo = new Instructor({
name: 'Fred the Second',
location: 'West Bedrock',
age: 39,
favLanguage: 'React',
specialty: 'Back-End',
catchPhrase: `Don't forget who...`
});

// Students//////////////////////////////////////////////////////

const John = new Student({
name: 'John',
location: 'New York',
age: 25,
previousBackground: 'Cashier',
className: 'Web25',
favSubjects: ['History','Math', 'Science']

});
const Doe = new Student({
name: 'Doe',
location: 'Florida',
age: 47,
previousBackground: 'The Florida Man',
className: 'PR',
favSubjects: ['Blacking Out','Getting in the News', 'Memes']

});

// Project Managers//////////////////////////////////////////////

const SpiderMan = new ProjectManager({
name:'Spiderman',
location: 'New York',
age: 26,
gradeClassname: 'Swinging From Buildings',
favInstructor: 'Not Iron Man',
});
const James = new ProjectManager({
name:'James Bond',
location: 'New York',
age: 50,
gradeClassname: 'Secret Agent 101',
favInstructor: 'Fred the Second',
});








//////// Test Logs //////////////////////////////////////////////
//Instructor
console.log(fred.demo(`Math!`));
console.log(instructorTwo.grade(Doe,'Creating Memes'));

//Student
console.log(John.listsSubjects());
console.log(John.PRAssignment('JavaScript II'));
console.log(Doe.sprintChallenge('JavaScript II'));

//Project Manager
console.log(SpiderMan.standUp('Avengers End Game Plan'));
console.log(SpiderMan.debugsCode(John,'Swinging from Buildings'));
console.log(James.standUp('FBI'));
console.log(James.debugsCode(John,'Sneaky walk'));
167 changes: 167 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,170 @@ Prototype Refactor
2. Your goal is to refactor all of this code to use ES6 Classes. The console.log() statements should still return what is expected of them.

*/


class GameObject{
constructor(attributes){
this.createdAt = attributes.createdAt;
this.name = attributes.name;
this.dimensions = attributes.dimensions;
}
destroy(){
return `${this.name} was removed from the game.`;
}
}

//Class Above for GameObject ^
// function GameObject(attributes){
// this.createdAt = attributes.createdAt;
// this.name = attributes.name;
// this.dimensions = attributes.dimensions;

// }
// GameObject.prototype.destroy = function() {
// return `${this.name} was removed from the game.`;
// }

/*
=== CharacterStats ===
* healthPoints
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
* should inherit destroy() from GameObject's prototype
*/



class CharacterStats extends GameObject{
constructor(characterAttributes){
super(characterAttributes);
this.healthPoints = characterAttributes.healthPoints;
}
takeDamage(){
return `${this.name} took damage.`;
}
}
// function CharacterStats(characterAttributes){
// GameObject.call(this, characterAttributes);
// this.healthPoints = characterAttributes.healthPoints;


// }
// CharacterStats.prototype = Object.create(GameObject.prototype);
// CharacterStats.prototype.takeDamage = function(){
// return `${this.name} took damage.`;
// }


/*
=== Humanoid (Having an appearance or character resembling that of a human.) ===
* team
* weapons
* language
* greet() // prototype method -> returns the string '<object name> offers a greeting in <object language>.'
* should inherit destroy() from GameObject through CharacterStats
* should inherit takeDamage() from CharacterStats
*/


class Humanoid extends CharacterStats{
constructor(humanoidAttributes){
super(humanoidAttributes);
this.team = humanoidAttributes.team;
this.weapons = humanoidAttributes.weapons;
this.language = humanoidAttributes.language;

}
greet(){
return `${this.name} offers a greeting in ${this.language}`;
}
}


// function Humanoid(humanoidAttributes){
// CharacterStats.call(this, humanoidAttributes);
// this.team = humanoidAttributes.team;
// this.weapons = humanoidAttributes.weapons;
// this.language = humanoidAttributes.language;


// }
// Humanoid.prototype = Object.create(CharacterStats.prototype);
// Humanoid.prototype.greet = function(){
// return `${this.name} offers a greeting in ${this.language}.`;
// }





/*
* Inheritance chain: GameObject -> CharacterStats -> Humanoid
* Instances of Humanoid should have all of the same properties as CharacterStats and GameObject.
* Instances of CharacterStats should have all of the same properties as GameObject.
*/

// Test you work by un-commenting these 3 objects and the list of console logs below:


const mage = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 2,
width: 1,
height: 1,
},
healthPoints: 5,
name: 'Bruce',
team: 'Mage Guild',
weapons: [
'Staff of Shamalama',
],
language: 'Common Tongue',
});

const swordsman = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 2,
width: 2,
height: 2,
},
healthPoints: 15,
name: 'Sir Mustachio',
team: 'The Round Table',
weapons: [
'Giant Sword',
'Shield',
],
language: 'Common Tongue',
});

const archer = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 1,
width: 2,
height: 4,
},
healthPoints: 10,
name: 'Lilith',
team: 'Forest Kingdom',
weapons: [
'Bow',
'Dagger',
],
language: 'Elvish',
});



console.log(mage.createdAt); // Today's date
console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
console.log(swordsman.healthPoints); // 15
console.log(mage.name); // Bruce
console.log(swordsman.team); // The Round Table
console.log(mage.weapons); // Staff of Shamalama
console.log(archer.language); // Elvish
console.log(archer.greet()); // Lilith offers a greeting in Elvish.
console.log(mage.takeDamage()); // Bruce took damage.
console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.