-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Katie Gorbell JavaScript-IV #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kgorbell
wants to merge
3
commits into
bloominstituteoftechnology:master
Choose a base branch
from
kgorbell:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,122 @@ | ||
| // CODE here for your Lambda Classes | ||
| class Person { | ||
| constructor(attributes) { | ||
| this.name = attributes.name; | ||
| this.age = attributes.age; | ||
| this.location = attributes.location; | ||
| this.gender = attributes.gender; | ||
| } | ||
| introduce() { | ||
| return `Hello, my name is ${this.name}, I am from ${this.location}.` | ||
| } | ||
| } | ||
|
|
||
| class Instructor extends Person{ | ||
| constructor(instructorAttrs) { | ||
| super(instructorAttrs); | ||
| this.specialty = instructorAttrs.specialty; | ||
| this.favLanguage = instructorAttrs.favLanguage; | ||
| this.catchPhrase = instructorAttrs.catchPhrase; | ||
| } | ||
| demo(subject) { | ||
| return `today we are learning about ${subject}.` | ||
| } | ||
| grade(student, subject) { | ||
| return `${student.name} receives a perfect score on ${subject} ` | ||
| } | ||
| } | ||
|
|
||
| const Gene = new Instructor({ | ||
| name: 'Gene Cousineau', | ||
| age: 65, | ||
| location: 'L.A.', | ||
| gender: 'M', | ||
| specialty: 'Teaching acting', | ||
| favLanguage: 'the language of Theatre', | ||
| catchPhrase: 'You\'re never going to see the inside of this acting class again!' | ||
| }); | ||
|
|
||
| const Fuches = new Instructor({ | ||
| name: 'Fuches', | ||
| age: 58, | ||
| location: 'L.A.', | ||
| gender: 'M', | ||
| specialty: 'handling the "business"', | ||
| favLanguage: 'money', | ||
| catchPhrase: 'BARRY, YOU\'RE ALIVE!', | ||
| }) | ||
|
|
||
|
|
||
|
|
||
| class Student extends Person { | ||
| constructor(studentAttrs) { | ||
| super(studentAttrs); | ||
| this.previousBackground = studentAttrs.previousBackground; | ||
| this.className = studentAttrs.className; | ||
| this.favSubjects = studentAttrs.favSubjects; | ||
| } | ||
| listsSubjects(arr) { | ||
| return `${this.favSubjects}; ` | ||
| } | ||
| PRAssignment(subject) { | ||
| return `${this.name} has submitted a PR for ${subject}`; | ||
| } | ||
| sprintChallenge(subject) { | ||
| return `${this.name} has begun a sprint challenge on ${subject}`; | ||
| } | ||
| } | ||
|
|
||
| const Barry = new Student({ | ||
| name: 'Barry Berkman', | ||
| age: 35, | ||
| location: 'L.A.', | ||
| gender: 'M', | ||
| previousBackground: 'Hitman', | ||
| className: 'Cousineau\'s Acting Class', | ||
| favSubjects: ['Acting', 'Shooting guns', 'daydreaming about Sally'], | ||
| }); | ||
|
|
||
| const Sally = new Student({ | ||
| name: 'Sally Reed', | ||
| age: 29, | ||
| location: 'L.A.', | ||
| gender: 'F', | ||
| previousBackground: 'Acting', | ||
| className: 'Cousineau\'s Acting Class', | ||
| favSubjects: ['Acting', 'Auditioning'], | ||
| }) | ||
|
|
||
| class ProjectManager extends Instructor { | ||
| constructor(PMAttrs) { | ||
| super(PMAttrs); | ||
| this.gradClassName = PMAttrs.gradClassName; | ||
| this.favInstructor = PMAttrs.favInstructor; | ||
| } | ||
| standUp(slackChannel) { | ||
| return `${this.name} announces to ${slackChannel}, @channel standy time!`; | ||
| } | ||
| debugsCode(student, subject) { | ||
| return `${this.name} debugs ${student.name}'s code on ${subject}`; | ||
| } | ||
| } | ||
|
|
||
| const Hank = new ProjectManager ({ | ||
| name: 'Noho Hank', | ||
| age: 32, | ||
| location: 'L.A.', | ||
| gender: 'M', | ||
| specialty: 'being a Mobster', | ||
| favLanguage: 'Chechen', | ||
| catchPhrase: 'We will find you, and we will kill you.', | ||
| gradClassName: 'right-hand man', | ||
| favInstructor: 'Goran Pazar', | ||
| }) | ||
|
|
||
|
|
||
| console.log(Gene.demo('MacBeth')); | ||
| console.log(Fuches.grade(Barry, 'Killing the target')); | ||
| console.log(Barry.listsSubjects(this.favSubjects)); | ||
| console.log(Sally.PRAssignment('playing MacBeth')); | ||
| console.log(Barry.sprintChallenge('stopping Chris from saying anything')); | ||
| console.log(Hank.standUp('the mobsters')); | ||
| console.log(Hank.debugsCode(Barry, 'CSS')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,40 +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; | ||
| class GameObject { | ||
| constructor(options) { | ||
| this. createdAt = options.createdAt; | ||
| this.dimensions = options.dimensions; | ||
| } | ||
| destroy() { | ||
| return `${this.name} was removed from the game.`; | ||
| } | ||
| } | ||
|
|
||
| GameObject.prototype.destroy = function() { | ||
| return `Object was removed from the game.`; | ||
| }; | ||
|
|
||
| function CharacterStats(characterStatsOptions) { | ||
| GameObject.call(this, characterStatsOptions); | ||
| this.hp = characterStatsOptions.hp; | ||
| this.name = characterStatsOptions.name; | ||
| class CharacterStats extends GameObject { | ||
| constructor(characterStatsOptions) { | ||
| super(characterStatsOptions); | ||
| this.hp = characterStatsOptions.hp; | ||
| this.name = characterStatsOptions.name; | ||
| } | ||
| takeDamage() { | ||
| return `${this.name} took damage.`; | ||
| } | ||
| } | ||
|
|
||
| CharacterStats.prototype = Object.create(GameObject.prototype); | ||
|
|
||
| CharacterStats.prototype.takeDamage = function() { | ||
| return `${this.name} took damage.`; | ||
| }; | ||
| // CharacterStats.prototype = Object.create(GameObject.prototype); | ||
|
|
||
| function Humanoid(humanoidOptions) { | ||
| CharacterStats.call(this, humanoidOptions); | ||
| this.faction = humanoidOptions.faction; | ||
| this.weapons = humanoidOptions.weapons; | ||
| this.language = humanoidOptions.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}.`; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! Nice job. |
||
| } | ||
|
|
||
| Humanoid.prototype = Object.create(CharacterStats.prototype); | ||
|
|
||
| Humanoid.prototype.greet = function() { | ||
| return `${this.name} offers a greeting in ${this.language}.`; | ||
| }; | ||
|
|
||
| const mage = new Humanoid({ | ||
| createdAt: new Date(), | ||
| dimensions: { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's an extra space for
this.createdAt