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

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

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


}

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

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

class Student extends Person {
constructor(stuAttrb){
super(stuAttrb);
this.previousBackground = stuAttrb.previousBackground;
this.className = stuAttrb.className;
this.favSubjects = stuAttrb.favSubjects;
}

listsSubjects (){
return console.log(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 TeamLeader extends Instructor{
constructor(tlAttrb){
super(tlAttrb);
this.gradClassName = tlAttrb.gradClassName;
this.favInstructor = tlAttrb.favInstructor;
}

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

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

const sam = new Instructor({
name: "sam",
location: "NY",
age: 47,
favLanguage: "HTML",
specialty: "Front-end",
catchPhrase: `Homies`
});

const jamal = new Instructor({
name: "jamal",
location: "San Francisco",
age: 33,
favLanguage: "Phyton",
specialty: "Fullstack",
catchPhrase: `Hey`
});

const fatih = new Student({
name: "Fatih",
location: "San Francisco",
age: 27,
favSubjects: ["HTML", "Java"],
previousBackground: "Engineer",
className:"WEPT11"
});

const laura = new Student({
name: "Laura",
location: "Las Vegas",
age: 37,
favLanguage: ["C++", "Python"],
previousBackground: "Front desk",
className:"WEPT11"
});

const ryan = new TeamLeader({
name: "Ryan",
location: "Arizona",
age: 38,
gradClassName: "Webt22",
favInstructor:"Sean"
});

const kenny = new TeamLeader({
name: "Kenny",
location: "Seattle",
age: 30,
gender: "male",
gradClassName: "Webt10",
favInstructor:"Britt"
});

console.log (fatih.speak());
console.log (ryan.speak());
console.log (kenny.standUp("CS11"));
console.log(laura.sprintChallenge("Javascript"));
console.log(ryan.debugsCode(fatih,"JS"));
console.log(sam.grade(laura, "CSS"));
150 changes: 150 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,156 @@ Prototype Refactor

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



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.

*/
//1.
// function GameObject(attr) {
// this.createdAt = attr.createdAt;
// this.name = attr.name;
// this.dimensions = attr.dimensions;

// }

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


class GameObject{
constructor(attr){
this.createdAt = attr.createdAt;
this.name = attr.name;
this.dimensions = attr.dimensions;
}
destroy(){
return `${this.name} was removed from the game.`;
}
}


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




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

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

class CharacterStats extends GameObject {
constructor(charAttr){
super(charAttr);
this.healthPoints=charAttr.healthPoints;
this.name = charAttr.name;
}
takeDamage(){
return `${this.name} took damage.`;
}
}






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

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

// Humanoid.prototype.greet = function() {
// return `${this.name} offers a greeting in ${this.language}`
// }


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