diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..4a5104632 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,78 @@ // 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(){ + return `Hello my name is ${this.name}, I am from ${this.location}`; +} +} + + +class Instructor extends Person{ + constructor(attributes2){ + super(attributes2); + this.specialty = attributes2.specialty; + this.favLanguage = attributes2.favLanguage; + this.catchPhrase = attributes2.catchPhrase; + } + demo(){ + return `Today we are learning about {subject}`; + } + grade(){ + return `{student.name} receives a perfect score on {subject}`; + } +} + +class Student extends Instructor{ + constructor(attributes3){ + super(attributes3); + this.previousBackground = attributes3.previousBackground; + this.className = attributes3.className; + this.favSubjects = attributes3.favSubjects; + } + listsSubjects(){ + return `${this.favSubjects}`; + } + PRAassignment(){ +return `${this.name} has submitted a PR for ${this.favSubjects}`; + } + sprintChallenge(){ + return `${this.name} has begun spring challenge ${this.favSubjects}`; + } +} + +class ProjectManager extends Student{ + constructor(attributes4){ + super(attributes4); + this.gradClassName = attributes4.gradClassName; + this.favInstructor = attributes4.favInstructor; + } + standUp(){ + return `${this.name} announces to {channel} @channel standy times!`; + } + debugsCode(){ + return `${this.name} debugs ${this.Student.name}'s code on ${this.favSubjects}`; + + } +} + +const fred = new Instructor({ + name: 'Fred', + location: 'Bedrock', + age: 37, + gender: 'male', + favLanguage: 'JavaScript', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies` + }); + + console.log(fred.speak()); + console.log(fred.demo()); + console.log(fred.grade()); + console.log() + console.log() \ No newline at end of file diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index e55ae39c0..80e21f8f1 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) { +class GameObject { + constructor(options){ this.createdAt = options.createdAt; this.dimensions = options.dimensions; } - -GameObject.prototype.destroy = function() { +destroy(){ return `Object was removed from the game.`; -}; +} +} -function CharacterStats(characterStatsOptions) { - GameObject.call(this, characterStatsOptions); + +class CharacterStats extends GameObject{ + constructor(characterStatsOptions){ + super(characterStatsOptions); this.hp = characterStatsOptions.hp; this.name = characterStatsOptions.name; } - -CharacterStats.prototype = Object.create(GameObject.prototype); - -CharacterStats.prototype.takeDamage = function() { +takeDamage(){ return `${this.name} took damage.`; -}; +} +} -function Humanoid(humanoidOptions) { - CharacterStats.call(this, humanoidOptions); +class Humanoid extends CharacterStats { + constructor(humanoidOptions){ + super(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}.`; -}; +greet(){ +return `${this.name} offers a greeting in ${this.language}.`; +} +} const mage = new Humanoid({ createdAt: new Date(),