diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..5cf261ccb 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,82 @@ // CODE here for your Lambda Classes +class Person{ + constructor(args){ + this.name = args.name; + this.age = args.age; + this.location = args.location; + this.gender = args.gender; + } + speak(){ + return `Hello my name is ${this.name}, I am from ${this.location}`; + } +} + +class Instructor extends Person{ + constructor(args){ + super(args); + this.specialty = args.specialty; + this.favLanguage = args.favLanguage; + this.catchPhrase = args.catchPhrase; + } + demo(subject){ + return `today we are learning about ${subject}`; + } + grade(student,subject){ + return `${student.name} receives a perfect score on ${subject}`; + } +} + +class Student extends Person { + constructor(args){ + super(args); + this.previousBackground = args.previousBackground; + this.className = args.className; + this.favSubjects = args.favSubjects; + } + listsSubjects(){ + this.favSubjects.forEach((subject) => { + console.log(subject); + }); + } + PRAssignment(subject){ + return `${this.name} has submitted a PR for ${subject}`; + } + sprintChallenge(subject){ + return `${this.name} has begun sprint challenge on ${subject}`; + } +} + +class ProjectManager extends Instructor { + constructor(args){ + super(args); + this.gradClassName = args.gradClassName; + this.favInstructor = args.favInstructor; + } + standUp(channel){ + console.log(`${this.name} announces to ${channel}, @channel standup times`); + } + debugsCode(student,subject){ + console.log(`${this.name} debugs ${student.name}'s code on ${subject}`); + } +} + +let callum = new ProjectManager({ + name: "Callum", + age: 25, + gender: "M", + location: "San Francisco", + specialty: "React", + favLanguage: "JavaScript", + catchPhrase: "Good Job", + gradClassName: "CS11", + favInstructor: "Josh" +}); + +let tom = new Student({ + name: "Tom", + age: 21, + gender: "M", + location: "wisconsin" +}); + +console.log(callum.debugsCode(tom,"math")); diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index e55ae39c0..18cc00dbc 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -2,16 +2,26 @@ // 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) { +/*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 `Object was removed from the game.`; + } } -GameObject.prototype.destroy = function() { +/*GameObject.prototype.destroy = function() { return `Object was removed from the game.`; -}; +};*/ -function CharacterStats(characterStatsOptions) { +/*function CharacterStats(characterStatsOptions) { GameObject.call(this, characterStatsOptions); this.hp = characterStatsOptions.hp; this.name = characterStatsOptions.name; @@ -21,9 +31,20 @@ CharacterStats.prototype = Object.create(GameObject.prototype); CharacterStats.prototype.takeDamage = function() { return `${this.name} took damage.`; -}; +};*/ + +class CharacterStats { + constructor(charStatsOpts){ + super(charStatsOpts); + this.hp = charStatsOpts.hp; + this.name = charStatsOpts.name; + } + takeDamage() { + return `${this.name} took damage.`; + } +} -function Humanoid(humanoidOptions) { +/*function Humanoid(humanoidOptions) { CharacterStats.call(this, humanoidOptions); this.faction = humanoidOptions.faction; this.weapons = humanoidOptions.weapons; @@ -34,7 +55,19 @@ Humanoid.prototype = Object.create(CharacterStats.prototype); Humanoid.prototype.greet = function() { return `${this.name} offers a greeting in ${this.language}.`; -}; +};*/ + +class Humanoid{ + constructor(humanoidOpts){ + super(humanoidOpts); + this.faction = humanoidOpts.faction; + this.weapons = humanoidOpts.weapons; + this.language = humanoidOpts.language; + } + greet(){ + return `${this.name} offers a greeting in ${this.language}.`; + } +} const mage = new Humanoid({ createdAt: new Date(),