diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..e67eccacb 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,46 @@ -// CODE here for your Lambda Classes +class Instructors extends Person{ + constructor (attributes){ + super(attributes); + this.specialty = attributes.specialty; + this.favLanguage = attributes.favLanguage; + this.catchPhrase = attributes.catchPhrase; + } + demo(subject){ + console.log(`Today we are learning about ${subject}.`) + } + grade(subject){ + console.log(`${this.name} receives a perfect score on ${subject}`) + } +} + +class Student extends Person{ + constructor (attributes){ + super(attributes); + this.previousBackground = attributes.previousBackground; + this.className = attributes.className; + this.favSubject = attributes.favSubject; + } + listsSubjects(){ + console.log(this.favSubject) + } + PRAssignment(subject){ + console.log(`${Student.name} has submitted a PR for ${subject}.`) + } + sprintChallenge(subject){ + console.log(`${Student.name} has begun sprint challenge on ${subject}.`) + } +} + +class PM extends Instructors{ + constructor (attributes){ + super(attributes); + this.gradClassName = attributes.gradClassName; + this.favInstructor = attributes.favInstructor; + } + standUp(name){ + console.log(`${name} announces to channel, @Channel stand times!`) + } + debugsCode(name,studentName,subject){ + console.log(`${name}debugs ${studentName}'s code on ${subject}`) + } +} \ No newline at end of file diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index 91424c9fa..95cea3894 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -3,7 +3,126 @@ Prototype Refactor 1. Copy and paste your code or the solution from yesterday +function GameObject(attributes){ + this.createdAt = attributes.createdAt; + this.dimensions = attributes.dimensions; + this.name = attributes.name; + GameObject.prototype.destroy = function(){ + return `${this.name} was removed from the game.` + } +} + +function CharacterStats(attributes){ + GameObject.call(this, attributes); + this.healthPoints = attributes.healthPoints; + this.name = attributes.name; +} +CharacterStats.prototype = Object.create(GameObject.prototype) + + CharacterStats.prototype.takeDamage = function(){ + return (`${this.name} took damage.`) + } + + function Humanoid(attributes){ + CharacterStats.call(this,attributes); + this.team = attributes.team; + this.weapons = attributes.weapons; + this.language = attributes.language; + } + Humanoid.prototype = Object.create(CharacterStats.prototype); + + Humanoid.prototype.greet = function(){ + return (`${this.name} offers a greeting in ${this.language}`) + } + + + 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.dimensions = attributes.dimensions; + this.name = attributes.name; + } + destroy(){ + return `${this.name} was removed from the game.` + } +} + +class CharacterStats extends GameObject{ + constructor (attributes){ + super(attributes); + this.healthPoints = attributes.healthPoints; + this.name = attributes.name; + } + takeDamage(){ + return (`${this.name} took damage.`) + } + +} + +class Humanoid extends CharacterStats{ + constructor (attributes){ + super(attributes); + this.team = attributes.team; + this.weapons = attributes.weapons; + this.language = attributes.language; + } + greet(){ + return (`${this.name} offers a greeting in ${this.language}`) + } +} + +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', + });