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
145 changes: 145 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,146 @@
// 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(insAttrs){
super(insAttrs);
this.specilty = insAttrs.specilty;
this.favLanguage = insAttrs.favLanguage;
this.catchPhrase = insAttrs.catchPhrase;
}
demo(subject){
console.log(`Today we are learning about ${subject}.`);
}
grade(student, subject){
console.log(`${student.name} receives a perfect score on ${subject}.`);
}
subtract(student, max){
console.log(`${student.grade}` - Math.floor(Math.random()*Math.floor(max)))
}
}

class Student extends Person {
constructor(studentAttrs){
super(studentAttrs);
this.previousBackground = studentAttrs.previousBackground;
this.className = studentAttrs.className;
this.favSubjects = studentAttrs.favSubjects;
this.grade = studentAttrs.grade;
}
listsSubjects(){
this.favSubjects.forEach(items => {
console.log(items);
});
}
PRAssignment(PRSubject){
console.log(`${this.name} has submitted a PR for ${PRSubject}.`)
}
sprintChallenge(SCSubject){
console.log(`${this.name} has begun sprint challenge on ${SCSubject}.`)
}
graduate(){
if (this.grade > 70){
console.log('Congratulations! You can graduate!');
} else {
console.log('Sorry, you need to work on your assignment!')
}
}
}

class ProjectManager extends Instructor {
constructor(PMAttrs){
super(PMAttrs);
this.gradClassName = PMAttrs.gradClassName;
this.favInstructor = PMAttrs.favInstructor;
}
standUP(channel){
console.log(`${this.name} announces to ${channel}, @channel standy times!`)
}
debugsCode(student, subject){
console.log(`${this.name} debugs ${student.name}'s code on ${subject}.`)
}
subtract(student, max){
console.log(`${student.grade}` - Math.floor(Math.random()*Math.floor(max)))
}
}

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

const brit = new Instructor({
name: 'Brit',
location: 'Vancouver',
age: 35,
favLanguage: 'Elm',
specilty: 'CSS',
catchPhrase: 'You can do this.'
})

const mandy = new Student({
name: 'Mandy',
location: 'New York City',
age: 28,
previousBackground: 'Accountant',
className: 'Web22',
favSubjects: ['HTML','CSS', 'JavaScript'],
grade: 88
})

const jack = new Student({
name: 'Jack',
location: 'South Africa',
age: 23,
previousBackground: 'Diamond dealer',
className: 'DS4',
favSubjects: ['Data Storytelling','Liner Algebra', 'Tree Ensembles'],
grade: 72
})

const ada = new ProjectManager({
name: 'Ada',
location: 'Sydney',
age: 30,
gradClassName: 'Web16',
favInstructor: 'Jason'
})

const mike = new ProjectManager({
name: 'Mike',
location: 'Portland',
age: 42,
gradClassName: 'DS1',
favInstructor: 'Julie'
})

console.log(fred.name);
fred.speak();
fred.demo('JavaScript');
console.log(`${brit.location}, ${brit.catchPhrase}`);
brit.grade(mandy, 'HTML');
console.log(mandy.previousBackground);
mandy.listsSubjects();
mandy.PRAssignment('JSON');
console.log(jack.favSubjects);
jack.sprintChallenge('Applied Modeling');
console.log(ada.gradClassName);
ada.standUP('Web23');
console.log(mike.favInstructor);
mike.debugsCode(ada, 'Statistical Tests');
brit.subtract(jack, 10);
ada.subtract(mandy, 12);
mandy.graduate();
94 changes: 94 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,97 @@ 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 GameObject {
constructor(GOattrs){
this.createdAt = GOattrs.createdAt;
this.name = GOattrs.name;
this.dimensions = GOattrs.dimensions;
}
destroy(){
return `${this.name} was removed from the game.`;
}
}

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


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