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
103 changes: 103 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,104 @@
// CODE here for your Lambda Classes
class Person {
constructor(attrs) {
this.name = attrs.name;
this.age = attrs.age;
this.location = attrs.location;
}

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

class Instructor extends Person {
constructor(attrs) {
super(attrs);
this.specialty = attrs.specialty;
this.favLanguage = attrs.favLanguage;
this.catchPhrase = attrs.catchPhrase;
}

demo(subject) {
console.log(`Today we are learning ${subject}`);
}

grade(Student, subject) {
console.log(`${Student.name} recieved a perfect score on ${subject}`);
}
}

class Student extends Person {
constructor(attrs) {
super(attrs);
this.previousBackground = attrs.previousBackground;
this.className = attrs.className;
this.favSubject = attrs.favSubject;
this.grade = attrs.grade;
}

listSubjects() {
this.favSubject.array.forEach(element => {
console.log(element);
});
}

PRAssignment(subject) {
console.log(`${this.name} has submitted a PR for ${subject}`);
}

sprintChallenge() {
console.log(`${this.name} has begun sprint challenge on ${subject}`);
}
}

class TeamLead extends Instructor {
constructor(attrs) {
super(attrs);
this.gradClassName = attrs.gradClassName;
this.favInstructor = attrs.favInstructor;
}

standUp(webpt9) {
console.log(`${this.name} announces to ${webpt9} @channel stanby times!`);
}


}

const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: "Don't forget the homies"
});

const mike = new Student({
name: 'Mike',
location: 'Ohio',
age: 59,
previousBackground: 'Wordpress',
className: 'IS1907_part_time',
favSubject: ['Html', 'CSS', 'JavaScript'],
grade: 80
});

const james = new TeamLead({
name: 'James',
location: 'Bedrock',
age: 37,
favLanguage: 'JavaScript',
specialty: 'React',
catchPhrase: "Don't forget the standups",
gradClassName: 'IS1907_part_time',
favInstructor: 'Fred'
});

console.log(fred);
console.log(mike);
console.log(james);
fred.speak();
mike.speak();
james.speak();
148 changes: 143 additions & 5 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,147 @@
/*


Prototype Refactor
// Prototype Refactor

1. Copy and paste your code or the solution from yesterday
// 1. Copy and paste your code or the solution from yesterday

// function GameObject(attributes) {
// this.createdAt = attributes.createdAt;
// this.name = attributes.name;
// this.dimensions = attributes.dimensions;
// }

// GameObject.prototype.destroy = function () {
// return `${this.name} was removed from the game`;
// }

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`;
}
}



// function CharacterStats(attributes) {
// GameObject.call(this, attributes);
// this.healthPoints = attributes.healthPoints;
// }

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

}

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

// CharacterStats.prototype = Object.create(GameObject.prototype);


// CharacterStats.prototype.takeDamage = function () {
// return `${this.name} took damage.`;
// };


// function Humanoid(attributes) {
// CharacterStats.call(this, attributes);
// this.team = attributes.team;
// this.weapons = attributes.weapons;
// this.language = attributes.language;
// }

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}.`;
}
}

// 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(),
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.

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

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.

*/