Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ const fred = new Instructor({
* Now that our students have a grade build out a method on the Instructor (this will be used by _BOTH_ instructors and PM's) that will randomly add or subtract points to a student's grade. _Math.random_ will help.
* Add a graduate method to a student.
* This method, when called, will check the grade of the student and see if they're ready to graduate from Lambda School
* If the student's grade is above a 70% let them graduate! Otherwise go back to grading their assignments to increase their score.
* If the student's grade is above a 70% let them graduate! Otherwise go back to grading their assignments to increase their score
113 changes: 113 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,114 @@
// CODE here for your Lambda Classes

// PERSON
class Person{
constructor(attributes) {
this.name = attributes.name,
this.age = attributes.age,
this.location = attributes.location
}

speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}



// INSTRUCTOR
class Instructor extends Person {
constructor(attributes) {
super(attributes);
this.specialty = attributes.specialty,
this.favLanguage = attributes.favLanguage,
this.cathPhrase = attributes.cathPhrase
}

demo(subject) {
return `Today we are learning ${subject}`
}

grade(subject) {
return `${this.name} receives a perfect score on ${subject}`
}
}

const britt = new Instructor({name:'Britt Hemming', age: 28, location: 'Toronto', specialty: 'Front End', favLanguage: 'Javascript', cathPhrase: 'ABC'})
const dan = new Instructor({name:'Dan Frehner', age: 35, location: 'Miami', specialty: 'Back End', favLanguage: 'CSS', cathPhrase: 'ABC'})
const austen = new Instructor({name:'Austen Allred', age: 30, location: 'SF', specialty: 'Business', favLanguage: 'HTML', cathPhrase: 'ABC'})





// STUDENTS
class Student extends Person {
constructor(attributes) {
super(attributes);
this.previousBackground = attributes.previousBackground,
this.className = attributes.className,
this.favSubjects = attributes.favSubjects
this.grade = attributes.grade;


const random = Math.floor((Math.random() * 100) + 1);
}

listsSubjects() {
for (let i = 0; i < this.favSubjects.length; i++) {
console.log(this.favSubjects[i]);
}
}

PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`
}
sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`
}
}

const sal = new Student({name:'Salvador Gonzalez', age: 28, location: 'Toronto', previousBackground: 'Front End', className: 'Javascript', favSubjects: ['Flexbox', 'CSS', 'HTML', 'JS'], grade: Math.floor((Math.random() * 100) + 1)});

console.log(sal.listsSubjects());


const adan = new Student({name:'Adan Rodriguez', age: 35, location: 'Miami', previousBackground: 'Back End', className: 'CSS', favSubjects: 'CSS Grid', grade: Math.floor((Math.random() * 100) + 1)});
const varrick = new Student({name:'Varrick Inzar', age: 30, location: 'SF', previousBackground: 'Business', className: 'HTML',favSubjects: 'CSS-in-JS', grade: Math.floor((Math.random() * 100) + 1)});



console.log(varrick.grade);


// TEAM LEADS
class TL extends Instructor {
constructor(attributes) {
super(attributes)
this.gradClassName = attributes.gradClassName,
this.favInstructor = attributes.favInstructor
}

standup(slack) {
return `${this.name} announces to ${slack}, @channel standy times!`
}

debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}

const melissa = new TL({name:'Melissa Murphy', age: 45, location: 'CA', specialty: 'Front End', favLanguage: 'Javascript', cathPhrase: 'ABC', gradClassName: 'WEB19', favInstructor: 'Dan Frehner'})

console.log(melissa.debugsCode(sal,'Flexbox'))







const brandonp = new TL({name:'Brandon Pampuch', age: 35, location: 'SEA', specialty: 'Front End', favLanguage: 'JS', cathPhrase: 'ABC', gradClassName: 'WEB19', favInstructor: 'Dan Frehner'})
const amanda = new TL({name:'Amanda Lane', age: 33, location: 'Miami', specialty: 'Front End', favLanguage: 'JS', cathPhrase: 'ABC', gradClassName: 'WEB19', favInstructor: 'Dan Frehner'})


183 changes: 183 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,186 @@ 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.

*/


/*
Object oriented design is commonly used in video games. For this part of the assignment you will be implementing several constructor functions with their correct inheritance hierarchy.

In this file you will be creating three constructor functions: GameObject, CharacterStats, Humanoid.

At the bottom of this file are 3 objects that all end up inheriting from Humanoid. Use the objects at the bottom of the page to test your constructor functions.

Each constructor function has unique properties and methods that are defined in their block comments below:

/*
=== GameObject ===
*/
class GameObject {
constructor(attributes) {
this.createdAt = attributes.createdAt,
this.name = attributes.name,
this.dimensions = attributes.dimensions
}

destroy() {
return `${this.name} was removed from the game.`;
}
}

const halo = new GameObject({
createdAt: 34,
name: 'LC Carrier',
dimensions: '100 GB'
});
console.log(halo.destroy());





/*
=== CharacterStats ===
*/
class CharacterStats extends GameObject {
constructor(attributes) {
super(attributes);
this.healthPoints = attributes.healthPoints
}

takeDamage() {
return `${this.name} took damage`
}

}

const char = new CharacterStats({
createdAt: '19',
name: 'Jojo Simard',
dimensions: '30',
healthPoints: 34
});

console.log(char.destroy());


/*
=== Humanoid (Having an appearance or character resembling that of a human.) ===
*/
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}`
}
}

const huma = new Humanoid({
createdAt: '12-10-1992',
name: 'Superman',
dimension: '12 * 12',
team: 'Good Guys',
weapons: 'Snipper',
language: 'Chinese',
})
console.log(huma.destroy());


/*
=== 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!


/*
* 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.










// Stretch task:
// * Create Villain and Hero constructor functions that inherit from the Humanoid constructor function.
// * Give the Hero and Villains different methods that could be used to remove health points from objects which could result in destruction if health gets to 0 or drops below 0;
// * Create two new objects, one a villain and one a hero and fight it out with methods!