From 5322c7d6ca4355a3f5e04f298fa9e398d766c282 Mon Sep 17 00:00:00 2001 From: BryanGf Date: Thu, 13 Sep 2018 11:06:27 -0700 Subject: [PATCH 1/3] Refractored --- assignments/prototype-refactor.js | 54 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index e55ae39c0..d88a2f7a4 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -2,39 +2,41 @@ // 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; -} - -GameObject.prototype.destroy = function() { - return `Object was removed from the game.`; -}; +class GameObject { + constructor(options) { + this.createdAt = options.createdAt; + this.dimensions = options.dimensions; + } -function CharacterStats(characterStatsOptions) { - GameObject.call(this, characterStatsOptions); - this.hp = characterStatsOptions.hp; - this.name = characterStatsOptions.name; + destroy() { + return `Object was removed from the game.`; + } } -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 CharacterStats extends GameObject { + constructor(characterStatsOptions) { + super(characterStatsOptions); + this.hp = characterStatsOptions.hp; + this.name = characterStatsOptions.name; + } + takeDamage() { + return `${this.name} took damage.`; + } } -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({ createdAt: new Date(), From 7e97fe73babf715f86e5fd4338a578c6ceedd56b Mon Sep 17 00:00:00 2001 From: BryanGf Date: Thu, 13 Sep 2018 12:18:35 -0700 Subject: [PATCH 2/3] Almost done just need more objects and fix one method --- assignments/lambda-classes.js | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..a690164a3 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,102 @@ // CODE here for your Lambda Classes +class Person { + constructor(personInfo) { + this.name = personInfo.name; + this.age = personInfo.age; + this.location = personInfo.location; + this.gender = personInfo.gender; + + } + + speak() { + console.log(`Hello my name is ${this.name}, I am from ${this.location}`) + } +} + +class Instructor extends Person { + constructor(instructorInfo) { + super(instructorInfo); + this.specialty = instructorInfo.specialty; + this.favLanguage = instructorInfo.favLanguage; + this.catchPhrase = instructorInfo.catchPhrase; + } + + demo(subject) { + console.log(`Today we are learning about ${subject}`); + } + + grade(student, subject) { + console.log(`${student.name} recieves a perfect score on ${subject}`); + } + } + +class Student extends Person { + constructor(studentInfo) { + super(studentInfo); + this.previousBackground = studentInfo.previousBackground; + this.className = studentInfo.previousBackground; + this.favSubjects = studentInfo.favSubjects; + } + + listsSubjects() { + + } + + PRAssignment(subject) { + console.log(`${this.name} has submitted a PR for ${subject}`); + } + + sprintChallenege(subject) { + console.log(`${this.name} has begun sprint challenge on ${subject}`) + } +} + +class ProjectManager extends Instructor { + constructor(pmInfo) { + super(pmInfo); + this.gradClassName = pmInfo.gradClassName; + this.favInstructor = pmInfo.favInstructor; + } + + standUp(channel) { + console.log(`${this.name} announces to ${channel}, @channel standy times!`); + } + + debugsCode(student, subject) { + console.log(`${this.name} debugs ${student.name}'s code on ${subject}`) + } + +} + +const instructorBobby = new Instructor({ + name: 'Bobby', + age: 31, + location: 'Canada', + gender: 'M', + specialty: 'redux', + favLanguage: 'JavaScript', + catchPhrase: 'YEET' +}) + +const studentPam = new Student({ + name: 'Pam', + age: 21, + location: 'U.S', + gender: 'F', + previousBackground: 'University of Somewhere', + className: 'CS132', + favSubjects: ['Html', 'CSS', 'JavaScript'] +}) + +const pmJohn = new ProjectManager({ + name: 'John', + age: 23, + location: 'U.S', + gender: 'M', + specialty: 'React', + favLanguage: 'Python', + catchPhrase: 'Sheep sleep', + gradClassName: 'CS13', + favInstructor: 'Bobby' +}) + From bdde0b810141bbb3487765c3324111eece03b9c2 Mon Sep 17 00:00:00 2001 From: BryanGf Date: Thu, 13 Sep 2018 12:40:36 -0700 Subject: [PATCH 3/3] Complete along with tests --- assignments/lambda-classes.js | 125 +++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 3 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index a690164a3..0af0fae92 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -39,7 +39,9 @@ class Student extends Person { } listsSubjects() { - + console.log(this.favSubjects[0]); + console.log(this.favSubjects[1]); + console.log(this.favSubjects[2]); } PRAssignment(subject) { @@ -73,9 +75,29 @@ const instructorBobby = new Instructor({ age: 31, location: 'Canada', gender: 'M', - specialty: 'redux', + specialty: 'Redux', favLanguage: 'JavaScript', - catchPhrase: 'YEET' + catchPhrase: 'Yeet Yeet' +}) + +const instructorAsh = new Instructor({ + name: 'Ash', + age: 58, + location: 'Canada', + gender: 'M', + specialty: 'React', + favLanguage: 'JavaScript', + catchPhrase: 'Beep Beep' +}) + +const instructorKeil = new Instructor({ + name: 'Keil', + age: 36, + location: 'Sweden', + gender: 'M', + specialty: 'Vue', + favLanguage: 'Python', + catchPhrase: 'Tweet Tweet' }) const studentPam = new Student({ @@ -88,6 +110,26 @@ const studentPam = new Student({ favSubjects: ['Html', 'CSS', 'JavaScript'] }) +const studentGee = new Student({ + name: 'Gee', + age: 20, + location: 'Canada', + gender: 'F', + previousBackground: 'University of Yeet', + className: 'CS182', + favSubjects: ['Python', 'React', 'JavaScript'] +}) + +const studentLee = new Student({ + name: 'Lee', + age: 18, + location: 'France', + gender: 'M', + previousBackground: 'Cashier (No experience)', + className: 'CS101', + favSubjects: ['Html', 'SQL', 'C++'] +}) + const pmJohn = new ProjectManager({ name: 'John', age: 23, @@ -100,3 +142,80 @@ const pmJohn = new ProjectManager({ favInstructor: 'Bobby' }) +const pmFino = new ProjectManager({ + name: 'Fino', + age: 20, + location: 'Brazil', + gender: 'M', + specialty: 'Redux', + favLanguage: 'C++', + catchPhrase: 'Meet Meet', + gradClassName: 'CS13', + favInstructor: 'Keil' +}) + +const pmEmery = new ProjectManager({ + name: 'Emery', + age: 23, + location: 'U.S', + gender: 'M', + specialty: 'node', + favLanguage: 'Java', + catchPhrase: 'Creep Creep', + gradClassName: 'CS12', + favInstructor: 'Ash' +}) + +//PM TESTS +pmEmery.demo('React'); +pmEmery.debugsCode(studentPam, 'React'); +pmEmery.grade(studentPam, 'Vue'); +pmEmery.speak() +pmEmery.standUp('fsw-13'); + +pmFino.demo('React'); +pmFino.debugsCode(studentPam, 'React'); +pmFino.grade(studentPam, 'Vue'); +pmFino.speak() +pmFino.standUp('fsw-13'); + +pmJohn.demo('React'); +pmJohn.debugsCode(studentPam, 'React'); +pmJohn.grade(studentPam, 'Vue'); +pmJohn.speak() +pmJohn.standUp('fsw-13'); + +//STUDENT TESTS + +studentPam.listsSubjects(); +studentPam.PRAssignment('React'); +studentPam.speak() +studentPam.sprintChallenege('React'); + +studentGee.listsSubjects(); +studentGee.PRAssignment('React'); +studentGee.speak() +studentGee.sprintChallenege('React'); + +studentLee.listsSubjects(); +studentLee.PRAssignment('React'); +studentLee.speak() +studentLee.sprintChallenege('React'); + +//INSTRUCTOR TESTS + +instructorAsh.demo('React'); +instructorAsh.grade(studentPam, 'Vue'); +instructorAsh.speak() + +instructorBobby.demo('React'); +instructorBobby.grade(studentPam, 'Vue'); +instructorBobby.speak() + +instructorKeil.demo('React'); +instructorKeil.grade(studentPam, 'Vue'); +instructorKeil.speak() + + + +