diff --git a/assignments/lambda-classes.js b/assignments/lambda-classes.js index 71acfca0e..7d4138eeb 100644 --- a/assignments/lambda-classes.js +++ b/assignments/lambda-classes.js @@ -1 +1,174 @@ // CODE here for your Lambda Classes +//Parent +class Parent { + constructor(attributes) { + this.newName = attributes.name; + this.newAge = attributes.age; + this.newLocation = attributes.location; + } + +//Method + speak() { + return `Hello my name is ${this.name}, I am from ${this.location}.`; + console.log(speak()); + } +} +//--------------------------- +//Child +class Child extends Parent { + constructor(resume) { + super(resume); + this.newSpecialty = resume.specialty; + this.newfavLanguage = resume.favLanguage; + this.newcatchPhrase = resume.catchPhrase; + + } + +//Methods + demo(subject) { + return `Today we are learning about ${subject}.`; + console.log(demo(subject)); + + } + + grade(student, subject) { + return `Hello ${student.name}receives a perfect score on ${subject}.`; + console.log(grade('Kara','hello')) + } + +} + + + +//--------------------------- +//Grandchild +class GrandChild extends Child { + constructor(report) { + super(report); + this.newPreviousBackground = report.previousBackground; + this.newClassName = report.className; + this.newFavSubjects = report.favSubjects; + + } + +//Methods + listSubjects(student, favSubjects) {// a method that logs out all of the student's favoriteSubjects one by one. + return `${student.name}receives a perfect score on ${this.favSubjects}.`; + console.log(listSubjects()); + } + PRAssignment() {//a method that receives a subject as an argument and logs out that the student.name has submitted a PR for {subject} + return `${student.name}receives a perfect score on ${subject}.`; + console.log(PRAssignment()); + } + sprintChallenge() {//similar to PRAssignment but logs out student.name has begun sprint challenge on {subject} + return ``; + } +} + +//--------------------------- +//GreatGrandchild +class GreatGrandchild extends GrandChild { + constructor(personal) { + super(personal); + this.newstandUp = personal.standup; + this.newFavInstructor = personal.favInstructor; + + } + +//Method + standUp() {//a method that takes in a slack channel and logs `{name} announces to {channel}, @channel standy times!​​​​​ + return ``; + } + debugsCodes(student, subject) {//a method that takes in a student object and a subject and logs out {name} debugs {student.name}'s code on {subject} + return ``; + } +} + + + + + +//----Objects==== +//----Parent------ +//1. +const firstPerson = new Parent({ + name: 'Gildo', + age: 11, + location: 'New Brunswick' +}); + +//2. +const secondPerson = new Parent({ + name: 'Galarny', + age: 13, + location: 'San Salvador', + }); +const thirdPerson = new Parent({ + name: 'Beckwith', + age: 26, + location: 'Calgary' + }); + + +//----- Child ------ +//1. +const firstInstructor = new Child({ + specialty: 'History', + favLanguage: 'Dothraky', + catchPhrase: 'You know nuthin' +}); + +//2. +const secondInstructor = new Child({ + specialty: 'Alchemy', + favLanguage: 'Elvin', + catchPhrase: 'Tu-wotha' +}); + + +//3. +const thirdInstructor = new Child({ + specialty: 'metalurgy', + favLanguage: 'muckduck', + catchPhrase: 'All hands in the pot', +}); + +//---- Grandchild ----- +//1. +const firstStudent = new GrandChild({ + previousBackground: 'Detroit auto worker', + className: 'webpt11' , + favSubjects: ['javascript', 'html', 'css'], +}); + +//2. +const d = new GrandChild({ + previousBackground: 'coal miner', + className: 'webpt11', + favSubjects: ['javascript', 'html', 'css'] +}); + +//3. +const z = new GrandChild({ + previousBackground: 'truck driver', + className: 'webpt11', + favSubjects: ['javascript', 'html', 'css'], +}); +//---- Great Grand Child ------ +//1. +const g = new GreatGrandchild({ + gradClassName: 'webpt11', + favInstructor: 'Josh Knell', +}); + +//2. +const y = new GreatGrandchild({ + gradClassName: 'webpt11', + favInstructor: 'Josh Knell', +}); + +//3. +const m = new GreatGrandchild({ + gradClassName: 'webpt11', + favInstructor: 'Josh Knell', +}); diff --git a/assignments/prototype-refactor.js b/assignments/prototype-refactor.js index 91424c9fa..b1e995980 100644 --- a/assignments/prototype-refactor.js +++ b/assignments/prototype-refactor.js @@ -1,4 +1,4 @@ -/* +/* Prototype Refactor @@ -6,4 +6,132 @@ 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. +class Parent { + constructor(attributes){ + this.newAge = attributes.age; + this.newName = attributes.name; + this.newLocation = attributes.location; + this.newPhrase= attributes.phrase; + } + //Methods + speak () { + return `${this.newName} says ${this.newPhrase}`; + } + location() { + return `${this.newName} says ${this.newPhrase}`; + } + }//Parent + + + class Child extends Parent{ + constructor(childAttributes){ + super(childAtttributes); + this.toy = childAttributes.toy; + } + speak () { + return `${this.newName} says ${this.newPhrase}`; + console.log(speak()); + + } + + }//Child +-------------------------------------------------------------------- */ +class GameObject { + constructor(objects) { + this.createdAt = objects.createdAt; + this.name = objects.name; + this.dimensions = objects.dimensions; + } + destroy() { + return `${this.name} was removed from the game.`; + + } + +} + +class CharacterStats extends GameObject{ + constructor(stats) { + super(stats); + this.healthPoints = stats.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}`; + } +} + +// 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.