diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..f03cba89d 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,60 @@ -// CODE here for your Lambda Classes +class Person { + constructor(attributes) { + this.name = attributes.name; + this.age = attributes.age; + this.location = attributes.location; + this.gender = attributes.gender; + } + speak() { + console.log(`Hello my name is ${this.name}, I am from ${this.location}`); + } +} + +class Instructor extends Person { + constructor(instructorAttributes) { + super(instructorAttributes); + this.specialty = instructorAttributes.specialty; + this.favLanguage = instructorAttributes.favLanguage; + this.catchPhrase = instructorAttributes.catchPhrase; + } + demo(subject) { + console.log(`Today we are learning about ${subject}`) + } + grade(student, subject) { + `${student.name} receives a perfect score on ${subject}` + } +} + +class Student extends Person { + constructor(studentAttributes) { + super(studentAttributes); + this.previousBackground = studentAttributes.previousBackground; + this.className = studentAttributes.className; + this.favSubjects = studentAttributes.favSubjects; + } + listsSubjects() { + for (subject of this.favSubjects) { + console.log(subject); + } + } + 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(pmAttributes) { + super(pmAttributes); + this.gradClassName = pmAttributes.gradClassName; + this.favInstructor = pmAttributes.favInstructor; + } + standUp(channel) { + console.log(`${this.name} announces to ${channel}, @channel standby times!`); + } + debugsCode(student, subject) { + console.log(`${this.name} debug's ${student.name}\'s code on ${subject}`); + } +} \ No newline at end of file diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index e55ae39c0..5218a2aef 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -2,39 +2,39 @@ // 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; +class GameObject { + constructor (options) { + this.createdAt = options.createdAt; + this.dimensions = options.dimensions; + } + destroy() { + return `${this.name} was removed from the game.`; + } } -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; +class CharacterStats extends GameObject { + constructor(characterStatsOptions) { + super(characterStatsOptions); + this.hp = characterStatsOptions.hp; + this.name = characterStatsOptions.name; + } + takeDamage() { + return `${this.name} took damage.`; + } } -CharacterStats.prototype = Object.create(GameObject.prototype); - -CharacterStats.prototype.takeDamage = function() { - return `${this.name} took damage.`; -}; - -function Humanoid(humanoidOptions) { - CharacterStats.call(this, humanoidOptions); - this.faction = humanoidOptions.faction; - this.weapons = humanoidOptions.weapons; - this.language = humanoidOptions.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}.`; + } } -Humanoid.prototype = Object.create(CharacterStats.prototype); - -Humanoid.prototype.greet = function() { - return `${this.name} offers a greeting in ${this.language}.`; -}; const mage = new Humanoid({ createdAt: new Date(),