8000 Greg hayes by hayesdev · Pull Request #680 · bloominstituteoftechnology/JavaScript-IV · GitHub
[go: up one dir, main page]

Skip to content

Greg hayes #680

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
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,131 @@
// CODE here for your Lambda Classes

class Person {
constructor(attribute) {
this.name = attribute.name;
this.age = attribute.age;
this.location = attribute.location;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}. `;
}
}

class Instructor extends Person {
constructor(attribute) {
super(attribute);
this.specialty = attribute.specialty;
this.favLanguage = attribute.favLanguage;
this.catchPhrase = attribute.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}.`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${this.subject}!`;
}
}

class Student extends Person {
constructor(attribute) {
super(attribute);
this.previousBackground = attribute.previousBackground;
this.className = attribute.className;
this.favSubjects = attribute.favSubjects;
}
listsSubjects(favSubjects) {
return this.favSubjects;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR Assignment for ${subject}.`;
}
sprintChallenge(subject) {
return `${this.name} has begun the sprint challenge on ${subject}!`;
}
}

class ProjectManager extends Instructor {
constructor(attribute) {
super(attribute);
this.gradClassName = attribute.gradClassName;
this.favInstructor = attribute.favIntructor;
}
standUp(channel) {
return `${this.name} announces to ${channel}, @channel standy times!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student}'s code on ${subject}.`;
}
}

const student_one = new Student({
name: "Greg",
age: 30,
location: "Austin",
previousBackground: "Uber",
className: "Javascript II",
favSubjects: ["HTML", "Javascript", "CS"]
});

const student_two = new Student({
name: "Colin",
age: 28,
location: "Salt Lake City",
previousBackground: "Sales",
className: "Javascript II",
favSubjects: ["Javascript", "Redux"]
});

const student_three = new Student({
name: "Eric",
age: 22,
location: "San Antonio",
previousBackground: "Retail",
className: "Javascript II",
favSubjects: ["HTML", "CSS", "npm"]
});

const instructor_one = new Instructor({
name: "Brit Demming",
age: 31,
location: "Canada",
specialty: "Keepin' it real",
favLanguage: "Javascript, HTML, CSS",
catchPhrase: "You're gonna know all about my pets"
});

const instructor_two = new Instructor({
name: "Ryan Hamblin",
age: 32,
location: "Salt Lake City",
specialty: "Prototypical Inheritance",
favLanguage: "Javascript, React",
catchPhrase: "Put the keys in the car"
});

const projectManager_one = new ProjectManager({
name: "Don Whitely",
age: 40,
location: "Indianapolis",
specialty: "Troubleshooting",
favLanguage: "React, Python",
catchPhrase: "Hold em' or Fold em'",
gradClassName: "Web13",
favInstructor: "James Starks"
});

const projectManager_two = new ProjectManager({
name: "Joseph Hayden",
age: 30,
location: "Chicago",
specialty: "Keepin' it real",
favLanguage: "Javascript, Python",
catchPhrase: "Wubba Lubba Javascript",
gradClassName: "Web18",
favInstructor: "Brit Demming"
});

console.log(student_three.PRAssignment("CSS"));
console.log(projectManager_one.standUp("Web24"));
console.log(projectManager_two.debugsCode("Greg", "CSS"));
console.log(instructor_two.demo("callback functions"));
121 changes: 121 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,124 @@ 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.`
*
*/

class GameObject {
constructor(attribute) {
this.createdAt = attribute.createdAt;
this.name = attribute.name;
this.dimensions = attribute.dimensions;
} // closes constructor
// methods go here
destroy() {
return `${this.name} was removed from the game.`;
}
}

/*
=== CharacterStats ===
* healthPoints
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
* should inherit destroy() from GameObject's prototype
*/

class CharacterStats extends GameObject {
constructor(stats) {
super(stats);
this.healthPoints = stats.healthPoints;
}
takeDamage() {
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 '<object name> offers a greeting in <object language>.'
* should inherit destroy() from GameObject through CharacterStats
* should inherit takeDamage() from CharacterStats
*/

class Humanoid extends CharacterStats {
constructor(profile) {
super(profile);
this.team = profile.team;
this.weapons = profile.weapons;
this.language = profile.language;
}
greet() {
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.
0