-
Notifications
You must be signed in to change notification settings - Fork 2.2k
so much easier! #217
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
base: master
Are you sure you want to change the base?
so much easier! #217
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,93 @@ | ||
| // CODE here for your Lambda Classes | ||
|
|
||
| class Person { | ||
| constructor(yeet) { | ||
| this.name = yeet.name; | ||
| this.age = yeet.age; | ||
| this.location = yeet.location; | ||
| this.gender = yeet.gender; | ||
|
|
||
| } | ||
| speak() { | ||
| return `Hello my name is ${this.name} , I am from ${this.location}` | ||
| } | ||
| } | ||
|
|
||
| class Instructor extends Person { | ||
|
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. Perfect! |
||
| constructor(instruct) { | ||
| super(instruct) | ||
| this.specialty = instruct.specialty; | ||
| this.favLanguage = instruct.favLanguage; | ||
| this.catchPhrase = instruct.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(studentAttr){ | ||
| super(studentAttr) | ||
| this.previousBackground = studentAttr.previousBackground; | ||
| this.classname = studentAttr.classname; | ||
| this.favSubjects = studentAttr.favSubjects; | ||
| } | ||
| listsSubjects() { | ||
|
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. This method should be Given an array, which |
||
| return `${this.favSubjects}`; | ||
| } | ||
| 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 { | ||
|
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. Perfect! |
||
| constructor(pmOptions) { | ||
| super(pmOptions); | ||
| this.gradClassName = pmOptions.gradClassName; | ||
| this.favInstructor = pmOptions.favInstructor; | ||
| } | ||
| standup(channel) { | ||
| return `${this.name} announces to ${channel}, @channel standy times!`; | ||
| } | ||
| debugsCode(student, subject) { | ||
| return `${this.name} debugs ${student.name}'s code on ${subject}.`; | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| const fred = new Instructor({ | ||
|
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. Don't forget to test the ProjectManager as well. And try using your own test data, it's better practice than using existing code. |
||
| name: 'Fred', | ||
| location: 'Bedrock', | ||
| age: 37, | ||
| gender: 'male', | ||
| favLanguage: 'JavaScript', | ||
| specialty: 'Front-end', | ||
| catchPhrase: `Don't forget the homies` | ||
| }); | ||
|
|
||
| const bill = new Student({ | ||
| 'name': 'bill', | ||
| 'age': '1000000', | ||
| 'location': 'Currently on the Sun', | ||
| 'gender': 'Unknown', | ||
| 'previousBackground': 'Unknown', | ||
| 'className': 'CS1000000000000000', | ||
| 'favSubjects': ['Python', 'Javascript', 'HTML/CSS'] | ||
| }); | ||
|
|
||
|
|
||
| console.log(fred); | ||
| console.log(bill); | ||
| console.log(bill); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,39 +2,75 @@ | |
| // 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 { | ||
|
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. ✅ |
||
| constructor(options) { | ||
| this.createdAt = options.createdAt; | ||
| this.dimensions = options.dimensions; | ||
| } | ||
| destroy() { | ||
| return `Object was removed from the game.`; | ||
| } | ||
| } | ||
|
|
||
| GameObject.prototype.destroy = function() { | ||
| return `Object was removed from the game.`; | ||
| }; | ||
| class CharacterStats extends GameObject { | ||
|
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. ✅ |
||
| constructor(characterStatsOptions) { | ||
| super(characterStatsOptions) | ||
| this.hp = characterStatsOptions.hp; | ||
| this.name = characterStatsOptions.name; | ||
| } | ||
| takeDamage() { | ||
| return `${this.name} took damage.`; | ||
| } | ||
| } | ||
|
|
||
| function CharacterStats(characterStatsOptions) { | ||
| GameObject.call(this, characterStatsOptions); | ||
| this.hp = characterStatsOptions.hp; | ||
| this.name = characterStatsOptions.name; | ||
| class Humanoid extends CharacterStats { | ||
|
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. ✅ |
||
| 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}.`; | ||
| } | ||
| } | ||
|
|
||
| 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; | ||
| } | ||
|
|
||
| Humanoid.prototype = Object.create(CharacterStats.prototype); | ||
| // function GameObject(options) { | ||
| // this.createdAt = options.createdAt; | ||
| // this.dimensions = options.dimensions; | ||
| // } | ||
|
|
||
| Humanoid.prototype.greet = function() { | ||
| return `${this.name} offers a greeting in ${this.language}.`; | ||
| }; | ||
| // 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; | ||
| // } | ||
|
|
||
| // 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; | ||
| // } | ||
|
|
||
| // 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(), | ||
|
|
||
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.
Perfect!