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
97 changes: 97 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,98 @@
// CODE here for your Lambda Classes
class Person {
constructor(personObj) {
this.name = personObj.name;
this.age = personObj.age;
this.location = personObj.location;
this.gender = personObj.gender;
}

speak() {
console.log(`Hello my name is ${this.name}, I am from ${this.location}.`);
}
}

class Instructor extends Person {
constructor(instructorObj) {
super(instructorObj);
this.specialty = instructorObj.specialty;
this.favLanguage = instructorObj.favLanguage;
this.catchPhrase = instructorObj.catchPhrase;
}

demo(subject) {
console.log(`Today we are learning about ${subject}.`);
}

grade(student, subject) {
console.log(`${student.name} receives a perfect score on ${subject}.`);
}
}

class Student extends Person {
constructor(studentObj) {
super(studentObj);
this.previousBackground = studentObj.previousBackground;
this.className = studentObj.className;
this.favSubjects = studentObj.favSubjects;
}

listsSubjects() {
this.favSubjects.forEach(element => {
console.log(element);
});
}

PRAssignment(subject) {
console.log(`${this.name} has submitted a PR for ${subject}.`);
}

sprintChallenge(subject) {
console.log(`${this.name} has begun sprint challenge on ${subject}.`);
}
}

class ProjectManager extends Instructor {
constructor(pmObj) {
super(pmObj);
this.gradClassName = pmObj.gradClassName;
this.favInstructor = pmObj.favInstructor;
}

standUp(channel) {
console.log(`${this.name} announces to ${channel}, @${channel} standy times!`);
}

debugsCode(student, subject) {
console.log(`${this.name} debugs ${student.name}'s code on ${subject}.`);
}
}

const ben = new Student({
name: 'Ben Masterson',
age: 30,
location: 'Philadelphia',
gender: 'Male',
previousBackground: 'I.T. Technician',
className: 'CSPT2',
favSubjects: ['JavaScript', 'Node', 'React']
});

const JohnSpraulingForNetflix = new ProjectManager({
name: 'John Spraul',
age: 42,
location: 'Mom\'s Basement',
gender: 'Possibly Male',
specialty: 'Recording Code Challenges / Grading Projects',
favLanguage: 'JavaScript',
catchPhrase: 'Looks like you know what you\'re doing. Great job.',
gradClassName: 'CS5',
favInstructor: 'Himself'
});

console.log(ben);
ben.listsSubjects();
console.log(JohnSpraulingForNetflix);
JohnSpraulingForNetflix.grade(ben, 'JavaScript');
JohnSpraulingForNetflix.demo('JavaScript');
JohnSpraulingForNetflix.debugsCode(ben, 'Node.js Project');
86 changes: 61 additions & 25 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,76 @@
// Here we have a functioning solutoin to your challenge from yesterday.
// Here we have a functioning solution to your challenge from yesterday.
// Today 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.

function GameObject(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}
// function GameObject(options) {
// this.createdAt = options.createdAt;
// this.dimensions = options.dimensions;
// }

GameObject.prototype.destroy = function() {
return `Object was removed from the game.`;
};
class GameObject {
constructor(gameObjectData) {
this.createdAt = gameObjectData.createdAt;
this.dimensions = gameObjectData.dimensions;
}

function CharacterStats(characterStatsOptions) {
GameObject.call(this, characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
destroy() {
return 'Object was removed from the game.';
}
}

CharacterStats.prototype = Object.create(GameObject.prototype);
// GameObject.prototype.destroy = function() {
// return `Object was removed from the game.`;
// };

// function CharacterStats(characterStatsOptions) {
// GameObject.call(this, characterStatsOptions);
// this.hp = characterStatsOptions.hp;
// this.name = characterStatsOptions.name;
// }

// CharacterStats.prototype = Object.create(GameObject.prototype);

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

CharacterStats.prototype.takeDamage = function() {
return `${this.name} took damage.`;
};
class CharacterStats extends GameObject {
constructor(characterStatsData) {
super(characterStatsData);
this.hp = characterStatsData.hp;
this.name = characterStatsData.name;
}

function Humanoid(humanoidOptions) {
CharacterStats.call(this, humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.language;
takeDamage() {
return `${this.name} took damage.`;
}
}

Humanoid.prototype = Object.create(CharacterStats.prototype);
// function Humanoid(humanoidOptions) {
// CharacterStats.call(this, humanoidOptions);
// this.faction = humanoidOptions.faction;
// this.weapons = humanoidOptions.weapons;
// this.language = humanoidOptions.language;
// }

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

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

class Humanoid extends CharacterStats {
constructor(humanoidData) {
super(humanoidData);
this.faction = humanoidData.faction;
this.weapons = humanoidData.weapons;
this.language = humanoidData.language;
}

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

const mage = new Humanoid({
createdAt: new Date(),
Expand Down