From 00f750f2aac4f5cf9d3c02696d32e5b96fd5e5e4 Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Thu, 9 May 2019 16:30:22 -0400 Subject: [PATCH 1/9] refator done --- assignments/prototype-refactor.js | 162 ++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index 91424c9fa..55350bcfe 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -7,3 +7,165 @@ 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 === + * createdAt + * name + * dimensions (These represent the character's size in the video game) + * destroy() // prototype method that returns: `${this.name} was removed from the game.` +*/ +// function GameObject(attributes) { + // this.createdAt = attributes.createdAt; + // this.name = attributes.name; + // this.dimensions = attributes.dimensions; +// } + +// GameObject.prototype.destroy = function () { +// return `${this.name} was removed from the game.` +// } +class GameObject { + constructor(attributes) { + this.createdAt = attributes.createdAt; + this.name = attributes.name; + this.dimensions = attributes.dimensions; + } + destroy(){ + return `${this.name} was removed from the game.`; + } +} +class CharacterStats extends GameObject { + constructor(attributes) { + super(attributes); + this.healthPoints = attributes.healthPoints; + } + 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}.` + } +} + +/* + === CharacterStats === + * healthPoints + * takeDamage() // prototype method -> returns the string ' took damage.' + * should inherit destroy() from GameObject's prototype +*/ +// function CharacterStats(attributes) { +// this.healthPoints = attributes.healthPoints; +// GameObject.call(this, attributes); + +// } +// CharacterStats.prototype = Object.create(GameObject.prototype); + +// CharacterStats.prototype.takeDamage = function () { +// return `${this.name} took damage.` +// } + + + + + + + +/* + === Humanoid (Having an appearance or character resembling that of a human.) === + * team + * weapons + * language + * greet() // prototype method -> returns the string ' offers a greeting in .' + * should inherit destroy() from GameObject through CharacterStats + * should inherit takeDamage() from CharacterStats +*/ +// function Humanoid(attributes) { +// this.team = attributes.team; +// this.weapons = attributes.weapons; +// this.language = attributes.language; +// CharacterStats.call(this, attributes); + +// } +// Humanoid.prototype = Object.create(CharacterStats.prototype); + +// Humanoid.prototype.greet = function () { +// return `${this.name} offers a greeting in ${this.language}` +// } + + +/* + * Inheritance chain: GameObject -> CharacterStats -> Humanoid + * Instances of Humanoid should have all of the same properties as CharacterStats and GameObject. + * Instances of CharacterStats should have all of the same properties as GameObject. + */ + +// Test you work by un-commenting these 3 objects and the list of console logs below: + + +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 a5e6bb6ffd2004107b4595e8acf6f871ced32e66 Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Thu, 9 May 2019 16:41:57 -0400 Subject: [PATCH 2/9] refator done --- assignments/prototype-refactor.js | 70 ------------------------------- 1 file changed, 70 deletions(-) diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index 55350bcfe..b5160ba22 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -7,22 +7,6 @@ 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 === - * createdAt - * name - * dimensions (These represent the character's size in the video game) - * destroy() // prototype method that returns: `${this.name} was removed from the game.` -*/ -// function GameObject(attributes) { - // this.createdAt = attributes.createdAt; - // this.name = attributes.name; - // this.dimensions = attributes.dimensions; -// } - -// GameObject.prototype.destroy = function () { -// return `${this.name} was removed from the game.` -// } class GameObject { constructor(attributes) { this.createdAt = attributes.createdAt; @@ -54,60 +38,6 @@ class Humanoid extends CharacterStats { } } -/* - === CharacterStats === - * healthPoints - * takeDamage() // prototype method -> returns the string ' took damage.' - * should inherit destroy() from GameObject's prototype -*/ -// function CharacterStats(attributes) { -// this.healthPoints = attributes.healthPoints; -// GameObject.call(this, attributes); - -// } -// CharacterStats.prototype = Object.create(GameObject.prototype); - -// CharacterStats.prototype.takeDamage = function () { -// return `${this.name} took damage.` -// } - - - - - - - -/* - === Humanoid (Having an appearance or character resembling that of a human.) === - * team - * weapons - * language - * greet() // prototype method -> returns the string ' offers a greeting in .' - * should inherit destroy() from GameObject through CharacterStats - * should inherit takeDamage() from CharacterStats -*/ -// function Humanoid(attributes) { -// this.team = attributes.team; -// this.weapons = attributes.weapons; -// this.language = attributes.language; -// CharacterStats.call(this, attributes); - -// } -// Humanoid.prototype = Object.create(CharacterStats.prototype); - -// Humanoid.prototype.greet = function () { -// return `${this.name} offers a greeting in ${this.language}` -// } - - -/* - * Inheritance chain: GameObject -> CharacterStats -> Humanoid - * Instances of Humanoid should have all of the same properties as CharacterStats and GameObject. - * Instances of CharacterStats should have all of the same properties as GameObject. - */ - -// Test you work by un-commenting these 3 objects and the list of console logs below: - const mage = new Humanoid({ createdAt: new Date(), From 93f19e0e2305dd8a9ce87e2ed763bd6e9b597c2c Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Thu, 9 May 2019 19:49:26 -0400 Subject: [PATCH 3/9] Lambda Classes template --- assignments/lambda-classes.js | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..173cc208e 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,52 @@ // CODE here for your Lambda Classes +class Person { + constructor(stat){ + this.name = stat.name; + this.age = stat.age; + this.location = stat.location; + this.gender = stat.gender; + } + speak() { + return `Hello my name is ${this.name}, I am from ${this.location}.` + } +} +class Instructor extends Person { + constructor(stat){ + super(stat); + this.specialty = stat.specialty; + this.favLanguage = stat.favLanguage; + this.catchPhrase = stat .catchPhrase; + } + demo() { + console.log(`Today we are learning about ${this.subject}`) + } +} +class Student extends Person { + constructor(stat) { + super(stat); + this.className = stat.className; + this.favSubjects = stat.favSubjects; + } + listsSubjects() { + + } + PRAssignment() { + + } + sprintChallenge() { + + } +} +class ProjectManager extends Instructor { + constructor(stat) { + super(stat); + this.gradClassName = stat.gradClassName; + this.favInstructors = stat.favInstructors; + } + standUp() { + + } + debugsCode() { + + } +} \ No newline at end of file From 0adfc9542af96d16ca0d82413750fd4cfb2d6768 Mon Sep 17 00:00:00 2001 From: Jacob Tharp Date: Thu, 9 May 2019 20:38:57 -0400 Subject: [PATCH 4/9] Working on methords --- assignments/lambda-classes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 173cc208e..2c8adf619 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -16,6 +16,7 @@ class Instructor extends Person { this.specialty = stat.specialty; this.favLanguage = stat.favLanguage; this.catchPhrase = stat .catchPhrase; + this.subject = stat.subject; } demo() { console.log(`Today we are learning about ${this.subject}`) From 068244065521815c6e0850b2afa071d407438629 Mon Sep 17 00:00:00 2001 From: Jacob Tharp Date: Thu, 9 May 2019 21:07:08 -0400 Subject: [PATCH 5/9] Working on methords more --- assignments/lambda-classes.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 2c8adf619..dce556f99 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -18,8 +18,11 @@ class Instructor extends Person { this.catchPhrase = stat .catchPhrase; this.subject = stat.subject; } - demo() { - console.log(`Today we are learning about ${this.subject}`) + demo(subject) { + return `Today we are learning about ${this.subject}` + } + grade() { + return `${Student.name} recieves a perfect score on ${subject}.`; } } class Student extends Person { From 6a18a4291f56adea54304b309b0f59b4f4a60d9a Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Thu, 9 May 2019 22:36:28 -0400 Subject: [PATCH 6/9] fixing methods --- assignments/lambda-classes.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index dce556f99..b750340b7 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1,4 +1,5 @@ // CODE here for your Lambda Classes +"use strict" class Person { constructor(stat){ this.name = stat.name; @@ -51,6 +52,17 @@ class ProjectManager extends Instructor { } debugsCode() { - + } -} \ No newline at end of file +} +const fred = new Instructor({ + name: 'Fred', + location: 'Bedrock', + age: 37, + gender: 'male', + favLanguage: 'JavaScript', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies` + }); + fred.speak(); + console.log(); \ No newline at end of file From 71b00f0cf9904577e7d14a6b26fbd3d4e64ebd4e Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Thu, 9 May 2019 23:01:34 -0400 Subject: [PATCH 7/9] finnished Instructor Constructor --- assignments/lambda-classes.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index b750340b7..08b1f2456 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -22,8 +22,8 @@ class Instructor extends Person { demo(subject) { return `Today we are learning about ${this.subject}` } - grade() { - return `${Student.name} recieves a perfect score on ${subject}.`; + grade(Student) { + return `${Student.name} recieves a perfect score on ${this.subject}.`; } } class Student extends Person { @@ -62,7 +62,23 @@ const fred = new Instructor({ gender: 'male', favLanguage: 'JavaScript', specialty: 'Front-end', - catchPhrase: `Don't forget the homies` + catchPhrase: `Don't forget the homies`, + subject : `Science` }); - fred.speak(); - console.log(); \ No newline at end of file + const billy = new Student({ + name: 'Billy Bob Thortain', + location: 'The Hills', + age: 4, + gender: 'male', + className: 'Unibrows', + favSubjects: { + History: 100, + Math: 100, + Naptime: 100, + }, + + }); + + console.log(fred.speak()); + console.log (fred.demo()); + console.log(fred.grade(billy)); \ No newline at end of file From ae6940a76f1c7e78c874457a5715a9676a0f141d Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Thu, 9 May 2019 23:23:58 -0400 Subject: [PATCH 8/9] Set up objects --- assignments/lambda-classes.js | 90 ++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 08b1f2456..fe68d3866 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -63,7 +63,27 @@ const fred = new Instructor({ favLanguage: 'JavaScript', specialty: 'Front-end', catchPhrase: `Don't forget the homies`, - subject : `Science` + subject: `Science` + }); + const joe = new Instructor({ + name: 'Joe', + location: 'Your Moms House', + age: 29, + gender: 'male', + favLanguage: 'Python', + specialty: 'Back-end', + catchPhrase: `I forgot`, + subject: `Math` + }); + const kyile = new Instructor({ + name: 'kyile', + location: 'Grub', + age: 24, + gender: 'female', + favLanguage: 'Java', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies`, + subject: `Hystory` }); const billy = new Student({ name: 'Billy Bob Thortain', @@ -71,13 +91,69 @@ const fred = new Instructor({ age: 4, gender: 'male', className: 'Unibrows', - favSubjects: { - History: 100, - Math: 100, - Naptime: 100, - }, - + favSubjects:[ + 'History', + 'Math', + 'Naptime' + ] + }); + const silly = new Student({ + name: 'Silly Bob Thortain', + location: 'The Hills', + age: 4, + gender: 'male', + className: 'Unibrows', + favSubjects:[ + 'History', + 'Math', + 'Naptime' + ] +}); +const shrilly = new Student({ + name: 'Shrilly Bob Thortain', + location: 'The Hills', + age: 4, + gender: 'female', + className: 'Unibrows', + favSubjects:[ + 'History', + 'Math', + 'Naptime' + ] +}); +const kyle = new ProjectManager({ + name: 'Kyle', + location: 'Grub', + age: 24, + gender: 'female', + favLanguage: 'Java', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies`, + subject: `Hystory` }); + const penelope = new ProjectManager({ + name: 'Penelope', + location: 'Grub', + age: 24, + gender: 'female', + favLanguage: 'Java', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies`, + subject: `Math` + }); + const hailey = new ProjectManager({ + name: 'Hailey', + location: 'Grub', + age: 24, + gender: 'female', + favLanguage: 'Java', + specialty: 'Front-end', + catchPhrase: `Don't forget the homies`, + subject: `Science` + }); + + + console.log(fred.speak()); console.log (fred.demo()); From 86cf0cc9cea87ecf79b5c2c77d67946f36944d54 Mon Sep 17 00:00:00 2001 From: Jengopockets Date: Fri, 10 May 2019 00:15:12 -0400 Subject: [PATCH 9/9] MVP --- assignments/lambda-classes.js | 46 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index fe68d3866..e0b536381 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -20,10 +20,10 @@ class Instructor extends Person { this.subject = stat.subject; } demo(subject) { - return `Today we are learning about ${this.subject}` + return `Today we are learning about ${subject}` } - grade(Student) { - return `${Student.name} recieves a perfect score on ${this.subject}.`; + grade(Student,subject) { + return `${Student.name} recieves a perfect score on ${subject}.`; } } class Student extends Person { @@ -33,12 +33,14 @@ class Student extends Person { this.favSubjects = stat.favSubjects; } listsSubjects() { + return `${this.favSubjects}`; } - PRAssignment() { - + PRAssignment(subject) { + return `${this.name} has submitted a PR for ${subject}`; } - sprintChallenge() { + sprintChallenge(subject) { + return `${this.name} has begun sprint challenge on ${subject}`; } } @@ -48,11 +50,11 @@ class ProjectManager extends Instructor { this.gradClassName = stat.gradClassName; this.favInstructors = stat.favInstructors; } - standUp() { - + standUp(slackCh) { + return `${this.name} announces to ${slackCh}, @channel standy times!`; } - debugsCode() { - + debugsCode(Student,subject) { + return `${this.name} debugs ${Student.name}'s code on ${subject}` } } const fred = new Instructor({ @@ -73,7 +75,6 @@ const fred = new Instructor({ favLanguage: 'Python', specialty: 'Back-end', catchPhrase: `I forgot`, - subject: `Math` }); const kyile = new Instructor({ name: 'kyile', @@ -83,7 +84,6 @@ const fred = new Instructor({ favLanguage: 'Java', specialty: 'Front-end', catchPhrase: `Don't forget the homies`, - subject: `Hystory` }); const billy = new Student({ name: 'Billy Bob Thortain', @@ -92,8 +92,8 @@ const fred = new Instructor({ gender: 'male', className: 'Unibrows', favSubjects:[ - 'History', - 'Math', + 'History ', + 'Math ', 'Naptime' ] }); @@ -129,7 +129,8 @@ const kyle = new ProjectManager({ favLanguage: 'Java', specialty: 'Front-end', catchPhrase: `Don't forget the homies`, - subject: `Hystory` + gradClassName: 'fedora', + favInstructors: 'kylie' }); const penelope = new ProjectManager({ name: 'Penelope', @@ -139,7 +140,8 @@ const kyle = new ProjectManager({ favLanguage: 'Java', specialty: 'Front-end', catchPhrase: `Don't forget the homies`, - subject: `Math` + gradClassName: 'fedora', + favInstructors: 'kylie' }); const hailey = new ProjectManager({ name: 'Hailey', @@ -149,12 +151,18 @@ const kyle = new ProjectManager({ favLanguage: 'Java', specialty: 'Front-end', catchPhrase: `Don't forget the homies`, - subject: `Science` + gradClassName: 'fedora', + favInstructors: 'kylie' }); console.log(fred.speak()); - console.log (fred.demo()); - console.log(fred.grade(billy)); \ No newline at end of file + console.log (fred.demo("Science")); + console.log(fred.grade(billy,"Math")); + console.log(billy.listsSubjects()); + console.log(silly.PRAssignment("Math")); + console.log(shrilly.sprintChallenge("Science")) + console.log(hailey.standUp("thesbians")) + console.log(penelope.debugsCode(billy, "Maths"))