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
112 changes: 112 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
// CODE here for your Lambda Classes

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

//Instructor class

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

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

listsSubjects() {
this.favSubjects.forEach(function(element) {
console.log(element);
});
} //listSubjects() ends

PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
} //PRAssignment() ends

sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`;
} // sprintChallenge() ends
} // student class ends.

//ProjectManager class
class ProjectManager extends Instructor {
constructor(pmAttributes) {
super(pmAttributes);
this.gradClassName = pmAttributes.gradClassName;
this.favInstructor = pmAttributes.favInstructor;
}
//methods
standUp(channel) {
return `${this.name} announces to ${channel}, @channel standy times!​​​​​`;
} //standUp ends

debugsCode(Student, subject) {
return `${this.name} debugs ${Student.name}'s code on ${subject}`;
} //debugCode() ends.

}

//Object creation..

const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});

const ld = new Student({
name: 'LD',
location: 'NJ',
age: 37,
gender: 'Female',
previousBackground : 'C',
className : 'CS132',
favSubjects : ['HTML', 'CSS', 'JavaScript']
});

const pm = new ProjectManager({
name: 'PMO',
location: 'CA',
age: 47,
gender: 'Female',
gradClassName : 'CS14',
favInstructor : 'Sam'
});

console.log(`ProjectManager standUp() : ${pm.standUp('CS14')}`);
console.log("Student favSubjects : ")
ld.listsSubjects();

console.log("Instructor demo() : " +fred.demo("JavaScript"));
54 changes: 27 additions & 27 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
// Here we have a functioning solutoin 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.
class GameObject {
constructor(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.`;
destroy() {
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);
class CharacterStats extends GameObject {
constructor(characterStatsOptions) {
super(characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
}

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

function Humanoid(humanoidOptions) {
CharacterStats.call(this, humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.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(humanoidOptions) {
super(humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.language;
}
greet() {
return `${this.name} offers a greeting in ${this.language}.`;
}
};

const mage = new Humanoid({
Expand Down