Skip to content
Merged
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
162 changes: 162 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,163 @@
// CODE here for your Lambda Classes
class Person {
constructor(attributes){
this.name = attributes.name,
this.locat = attributes.locat,
this.age = attributes.age,
this.gender = attributes.age
}
speak(){
return `Hello, my name is ${this.name}, I am from ${this.locat}.`;
}
};

class Instructor extends Person{
constructor(attributes){
super(attributes);
this.favLang = attributes.favLang,
this.specialty = attributes.specialty,
this.catchPhrase = attributes.catchPhrase
}
demo(subject){
return `Today we are learning about ${subject}.`;
}
grade(student, subject){
return `${student.name} receives a perfect score on ${subject}!`;
}
teach(student){
student.grades += Math.round(Math.random()) * 2 - 1;
return `${student.name}, your new grade is ${student.grades}`;
}
};

class Student extends Person {
constructor(attributes){
super(attributes);
this.previousBackground = attributes.previousBackground,
this.className = attributes.className,
this.favSubjects = attributes.favSubjects,
this.grades = attributes.grades
}
listsSubjects(){
return this.favSubjects;
}
PRAssignment(subject){
return `${this.name} has submitted a PR for ${subject}.`;
}
sprintChallenge(subject){
return `${this.name} has begun sprint challenge on ${subject}.`;
}
graduate(){
if(this.grades >= 70){
return `Congrats ${this.name}!!!`;
} else {
return `Sorry, ${this.name}, back to school.`;
}
}
};

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



const arthur = new Instructor({
name: 'Arthur',
location: 'Montreal',
age: 37,
gender: 'male',
favLanguage: 'Java',
specialty: 'Front-end',
catchPhrase: `Hey`
});

const buster = new Instructor({
name: 'Buster',
location: 'Montreal',
age: 36,
gender: 'male',
favLanguage: 'CSS/LESS',
specialty: 'UI',
catchPhrase: `We're just specks of dust floating in space.`
});

const sueellen = new Student({
name: 'Sue Ellen',
location: 'Pointe-Claire',
age: 37,
gender: 'female',
grades: 96,
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Animals make better friends than people.`
});

const binky = new Student({
name: 'Binky',
location: 'Laval',
age: 39,
gender: 'male',
grades: 66,
favLanguage: 'Java',
specialty: 'Video Games',
catchPhrase: `My dad said he'd buy me a computer when it snows in July`
});

const francine = new Student({
name: 'Francine',
location: 'Longueuil',
age: 37,
gender: 'female',
grades: 79,
favLanguage: 'Ruby',
specialty: 'Meta Programming',
catchPhrase: `Over half the people on Earth are girls`
});

const muffy = new ProjectManager({
name: 'Muffy',
location: 'Saint-Eustache',
age: 36,
gender: 'female',
favLanguage: 'Ruby',
specialty: 'One-Upping',
catchPhrase: `Look ar her, trying to hold her head up high, despite her terrible posture.`
});

const dw = new ProjectManager({
name: 'Dora Winifred',
location: 'Montreal',
age: 30,
gender: 'female',
favLanguage: 'Python',
specialty: 'Data-Analysis',
catchPhrase: `I don't care about the president, I care about ponies.`
});

console.log(buster.teach(francine));
console.log(buster.teach(francine));
console.log(muffy.teach(binky));
console.log(muffy.teach(binky));
console.log(muffy.teach(binky));
console.log(arthur.teach(binky));
console.log(arthur.teach(binky));
console.log(arthur.teach(binky));
console.log(buster.teach(binky));
console.log(buster.teach(binky));
console.log(buster.teach(binky));
console.log(dw.teach(binky));
console.log(dw.teach(binky));
console.log(sueellen.graduate());
console.log(francine.graduate());
console.log(binky.graduate());
196 changes: 193 additions & 3 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,199 @@
/*

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(attributes){
this.createdAt = attributes.createdAt,
this.name = attributes.name,
this.dimensions = attributes.dimensions
}

1. Copy and paste your code or the solution from yesterday
destroy(){
return `${this.name} was removed from the game.`
}
};
/*
=== CharacterStats ===
*/
class CharacterStats extends GameObject{
constructor(charAttr){
super(charAttr);
this.healthPoints = charAttr.healthPoints
}
takeDamage() {
return `${this.name} took damage.`
}
};
/*
=== Humanoid ===
*/
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}`;
}

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.
annoy() {
return `${this.name} is tone-deaf but still sings to every song.`
}

taunt(prey) {
return `${this.name} thwarts ${prey.name}'s willpower by bringing in donuts every morning. ${prey.name}'s width increases to ${prey.dimensions.width}!`
}

pray() {
return `${this.name} offers to pray for you, making your soul cringe.`
}
}
/*
=== Villan ===
*/
class Villan extends Humanoid{
constructor(vilAttr){
super(vilAttr);
this.scheme = vilAttr.scheme
}

avoid(prey) {
return `${this.name} hides behind ${this.weapons[2]} instead of creating meaningful boundaries. ${prey.name} must relinquish native culture, customs and cease speaking ${prey.language}.`
}

distract(prey) {
return `${this.name} uses ${this.weapons[1]} to distract ${prey.name}. ${prey.name} walks away confused, with ${[prey.healthPoints - 2]} health points.`
}

harass() {
return `${this.name} uses ${this.weapons[1]} to marginalize the foreign or female.`
}

influence() {
return `${this.name} ${this.scheme[0]} by placing bought allies in powerful positions. `
}

disgrace() {
return `${this.name} ${this.scheme[1]} and gets away with it???`
}
}
/*
=== CHARACTERS ===
*/
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: 'The Old Words',
});

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: 'The 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',
});

const karen = new Humanoid ({
createdAt: new Date(),
dimensions: {
length: 2,
witdh: 4,
height: 1,
},
healthPoints: 8,
name: 'Karen',
team: 'New England Patriots',
weapons: [
'Crucifix',
'Empty Calories',
],
language: 'Mom'
})

const richWhiteNarcissist = new Villan ({
createdAt: new Date(),
dimentions: {
length: 3,
width: 3,
height: 3,
},
healthPoints : 30,
name: 'Drumpf',
team: 'America',
weapons: [
'Money',
'The Best Words',
'Walls',
],
language: 'American',
scheme: [
'Stacks the Deck',
'Lies and Denies',
]
});
/*
=== COMMANDS ===
*/
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.

console.log(karen.team);
console.log(karen.greet());
console.log(karen.annoy());
console.log(karen.taunt(archer));
console.log(karen.pray());

console.log(richWhiteNarcissist.avoid(mage));
console.log(richWhiteNarcissist.distract(karen));
console.log(richWhiteNarcissist.harass());
console.log(richWhiteNarcissist.influence());
console.log(richWhiteNarcissist.disgrace());