diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..d1f069b05 Binary files /dev/null and b/.DS_Store differ diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..352d5a133 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,144 @@ // 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(){ + 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 { + constructor(pmAttr) { + super(pmAttr); + this.gradClassName = pmAttr.gradClassName, + this.favInstuctor = pmAttr.favInstuctor + } + standUp(channel) { + return `${this.name} announces to ${channel}, @channel standup times!` + } + 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', + 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', +}); + + +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 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