From 4ddd3abfcb609c7de657b6bc58e67b8fee4617f9 Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Thu, 17 Oct 2019 12:46:12 -0700 Subject: [PATCH 1/4] refactor done --- .DS_Store | Bin 0 -> 6148 bytes assignments/prototype-refactor.js | 138 ++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d1f069b055e82da15e37490cda539f06bb255b5b GIT binary patch literal 6148 zcmeHKIc~#13?vg30^GPvxnJ-P7J~DFd?3DH7*OIuNw3Q9%F{AD8bNkvH^xvPXP4rv zpeaOAM6~A!;D$AE4D?S2f{y^e25C2} zeU<Eo^g9;3)=7^y|N4{iTO&kM*E}FxK=94ui6!oX${Nm-JHIR`CP=Toe zud!WP|9^+ynE$6F?x+A2cq#?7S%0iMyi)eo*~?k4E$~mc)%?NDuyzW9w_~8UV{EJ) ezj;yA6{24G^XjI_Q3j71`>=q#a literal 0 HcmV?d00001 diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index 91424c9fa..86c65f3d3 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -7,3 +7,141 @@ Prototype Refactor 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. */ + +//GameObject Original code +// function GameObject(attribute){ +// this.createdAt = attribute.createdAt; +// this.name = attribute.name; +// this.dimensions = attribute.dimensions; +// } + +// GameObject.prototype.destroy = function () { +// return `${this.name} was removed from the game` +// }; + +//GameObject refactor +class GameObject { + constructor(gameAttribute) { + this.createdAt = gameAttribute.createdAt, + this.name = gameAttribute.name, + this.dimensions = gameAttribute.dimensions + } + destroy() { + return `${this.name} was removed from the game`; + } +} + +// CharacterStats Original Code + +// function CharacterStats(attribute) { +// GameObject.call(this,attribute); +// this.healthPoints = attribute.healthPoints; +// } + +// CharacterStats.prototype = Object.create(GameObject.prototype); + +// CharacterStats.prototype.takeDamage = function(){ +// return `${this.name} took damage` +// } + +//CharacterStats Refactor +class CharacterStats extends GameObject { + constructor(charcAttr) { + super(charcAttr); + this.healthPoints = charcAttr.healthPoints + } + takeDamage() { + return `${this.name} took damage`; + } +} + +// Humanoid Original Code + +// function Humanoid(attribute) { +// CharacterStats.call(this, attribute); +// this.team = attribute.team; +// this.weapons = attribute.weapons; +// this.language = attribute.language; +// } + +// Humanoid.prototype = Object.create(CharacterStats.prototype) + +// Humanoid.prototype.greet = function() { +// return '${this.name} offers a greeting in ${this.language}' +// } + +//Humanoid Refactor + +class Humanoid extends CharacterStats { + constructor(humanAttr) { + super(humanAttr); + this.team = humanAttr.team, + this.weapons = humanAttr.weapons, + this.language = humanAttr.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', + }); + + console.log(mage.createdAt); // Today's date + console.log(archer.dimensions); // { length: 1, width: 2, height: 4 } + console.log(swordsman.healthPoints); // 15 + console.log(mage.name); // Bruce + console.log(swordsman.team); // The Round Table + console.log(mage.weapons); // Staff of Shamalama + console.log(archer.language); // Elvish + console.log(archer.greet()); // Lilith offers a greeting in Elvish. + console.log(mage.takeDamage()); // Bruce took damage. + console.log(swordsman.destroy()); // Sir Mustachio was removed from the game. \ No newline at end of file From f7b4c91153d27d45717782f594df934dc75f3543 Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Thu, 17 Oct 2019 13:35:13 -0700 Subject: [PATCH 2/4] classes created --- assignments/lambda-classes.js | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..ca2cecbb7 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,63 @@ // CODE here for your Lambda Classes + + +class Person { + constructor(personAttr) { + this.name = personAttr.name, + this.age = personAttr.age, + this.location = personAttr.location + } + speak() { + return `Hello my name is Fred. I am from Bedrock where ${this.name} and ${this.location} are the object's own props.`; + } +} + +class Instructor extends Person { + constructor(instructorAttr){ + super(instructorAttr); + this.specialty = instructorAttr.specialty, + this.favLanguage = instructorAttr.favLanguage, + this.catchPhrase = instructorAttr.catchPhrase + } + demo(subject) { + return `Today we are learning about ${subject}`; + } + grade(student, subject) { + return `${student} receives a perfect score on ${subject}` + }///this one needs fixing +} + +class Student extends Person { + constructor(stuAttr){ + super(stuAttr); + this.previousBackground = stuAttr.previousBackground, + this.className = stuAttr.className, + this.favSubjects = stuAttr.favSubjects + } + listsSubjects(){ + + } + PRAssignment(name, subject){ + return `(name) has submitted a PR for (subject)` + } + sprintChallenge(){ + + } +} + +class ProjectManagers extends Instructors { + constructor(pmAttr){ + super(pmAttr); + this.gradClassName = pmAttr.gradClassName, + this.favInstuctor = pmAttr.favInstuctor + } + standUp(){ + + } + debugscode(){ + + } +} + + +console.log() \ No newline at end of file From b1528e17d3e9983d3d8dbca9381163f23098df7d Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Thu, 17 Oct 2019 15:33:19 -0700 Subject: [PATCH 3/4] created objects --- assignments/lambda-classes.js | 106 +++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 21 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index ca2cecbb7..1090820b5 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -15,49 +15,113 @@ class Person { class Instructor extends Person { constructor(instructorAttr){ super(instructorAttr); - this.specialty = instructorAttr.specialty, - this.favLanguage = instructorAttr.favLanguage, - this.catchPhrase = instructorAttr.catchPhrase + this.specialty = instructorAttr.specialty, + this.favLanguage = instructorAttr.favLanguage, + this.catchPhrase = instructorAttr.catchPhrase } demo(subject) { return `Today we are learning about ${subject}`; } grade(student, subject) { - return `${student} receives a perfect score on ${subject}` + return `${student.name} receives a perfect score on ${subject}` }///this one needs fixing } class Student extends Person { constructor(stuAttr){ super(stuAttr); - this.previousBackground = stuAttr.previousBackground, - this.className = stuAttr.className, - this.favSubjects = stuAttr.favSubjects + this.previousBackground = stuAttr.previousBackground, + this.className = stuAttr.className, + this.favSubjects = stuAttr.favSubjects } listsSubjects(){ - + return `${this.favSubjects}`; } PRAssignment(name, subject){ - return `(name) has submitted a PR for (subject)` + return `${student.name} has submitted a PR for ${subject}`; } - sprintChallenge(){ - + sprintChallenge(name, subject){ + return `${student.name} has begun sprint challenge on${subject}`; } } -class ProjectManagers extends Instructors { - constructor(pmAttr){ - super(pmAttr); - this.gradClassName = pmAttr.gradClassName, - this.favInstuctor = pmAttr.favInstuctor +class ProjectManager extends Instructor { + constructor(pmAttr) { + super(pmAttr); + this.gradClassName = pmAttr.gradClassName, + this.favInstuctor = pmAttr.favInstuctor } - standUp(){ - + standUp(name, channel) { + return `${name} announces to ${channel}, @channel standup times!` } - debugscode(){ - + debugscode(name, subject) { + return `${projectmang.name} debugs ${student.name}'s code on ${subject}` } } -console.log() \ No newline at end of file +const jason = new Instructor ({ + name: 'Jason Momoa', + location: 'Hawaii', + age: 38, + favLanguage: 'HTML', + specialty: 'works well with women', + catchPhrase: 'Hello my lovelies!' +}); + +const penelope = new Instructor ({ + name: 'Penelope Garcia', + location: 'San Francisco', + age: 35, + favLanguage: 'JavaScript', + specialty: 'hacking', + catchPhrase: 'Your friendly neighborhood Oracle of all things knowable and unknowable, at your service' +}); + +const sarah = new Student ({ + name: 'Sarah', + location: 'California', + age: 41, + favLanguage: 'JavaScript', + specialty: 'making things complicated', + catchPhrase: 'Sup fools?!', + previousBackground: 'Customer Service, Teacher', + className: 'Web25', + favSubjects: ['Music', 'HTML', 'JavaScript'] +}); + +const chanyeol = new Student ({ + name: 'Chanyeol', + location: 'Seoul', + age: 28, + favLanguage: 'CSS', + specialty: 'can play any instrument', + catchPhrase: 'Im the Happy Virus', + previousBackground: 'Kpop Idol', + className: 'Web400', + favSubjects: ['music', 'UX/UI', 'HTML'] +}) + + +const joscelyn = new ProjectManager ({ + name: 'Joscelyn', + location: 'Ohio', + age: 27, + favLanguage: 'JavaScript', + specialty: 'Super smash bros', + catchPhrase: 'Gotta Catch Em All', + gradClassName: 'CS15', + favInstructor: 'Brit' +}); + +const tommy = new ProjectManager ({ + name: 'Tommy', + location: 'Iowa', + age: 'guess', + favLanguage: 'C#', + specialty: 'Node.js', + catchPhrase: 'Whats sleep?', + gradClass: 'Web21', + favInstructor: 'Luis', +}) + From 895fcbe6d1d5bef2c58de668ecc1eed7e972f166 Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Thu, 17 Oct 2019 17:14:28 -0700 Subject: [PATCH 4/4] finished project --- assignments/lambda-classes.js | 39 +++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 1090820b5..352d5a133 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -23,7 +23,7 @@ class Instructor extends Person { return `Today we are learning about ${subject}`; } grade(student, subject) { - return `${student.name} receives a perfect score on ${subject}` + return `${student} receives a perfect score on ${subject}` }///this one needs fixing } @@ -37,11 +37,11 @@ class Student extends Person { listsSubjects(){ return `${this.favSubjects}`; } - PRAssignment(name, subject){ - return `${student.name} has submitted a PR for ${subject}`; + PRAssignment(subject){ + return `${this.name} has submitted a PR for ${subject}`; } - sprintChallenge(name, subject){ - return `${student.name} has begun sprint challenge on${subject}`; + sprintChallenge(subject){ + return `${this.name} has begun sprint challenge on ${subject}`; } } @@ -51,14 +51,22 @@ class ProjectManager extends Instructor { this.gradClassName = pmAttr.gradClassName, this.favInstuctor = pmAttr.favInstuctor } - standUp(name, channel) { - return `${name} announces to ${channel}, @channel standup times!` + standUp(channel) { + return `${this.name} announces to ${channel}, @channel standup times!` } - debugscode(name, subject) { - return `${projectmang.name} debugs ${student.name}'s code on ${subject}` + debugscode(student, subject) { + return `${this.name} debugs ${student}'s code on ${subject}` } } +const fred = new Instructor({ + name: 'Fred', + location: 'Bedrock', + age: 37, + favLanguage: 'JavaScript', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies` + }); const jason = new Instructor ({ name: 'Jason Momoa', @@ -100,7 +108,7 @@ const chanyeol = new Student ({ previousBackground: 'Kpop Idol', className: 'Web400', favSubjects: ['music', 'UX/UI', 'HTML'] -}) +}); const joscelyn = new ProjectManager ({ @@ -123,5 +131,14 @@ const tommy = new ProjectManager ({ catchPhrase: 'Whats sleep?', gradClass: 'Web21', favInstructor: 'Luis', -}) +}); + +console.log(fred.speak()); +console.log(jason.demo('Python')); +console.log(penelope.grade('Chad', 'CSS')); +console.log(sarah.listsSubjects()); +console.log(chanyeol.PRAssignment('Band')); +console.log(chanyeol.sprintChallenge('Pokemon')); +console.log(joscelyn.standUp('#Web3000')); +console.log(tommy.debugscode('Sarah', 'Swift')); \ No newline at end of file