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

speak() {
console.log(`Hello, my name is ${this.name}, I'm from ${this.location}`);
}
}
class Instructor extends Person {
constructor(attributes) {
super(attributes);
this.specialty = attributes.specialty;
this.favLanguage = attributes.favLanguage;
this.catchPhrase = attributes.catchPhrase;
}

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

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

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

listsSubjects() {
this.favSubjects.forEach(item => console.log(item));
}

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

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

class ProjectManager extends Person {
constructor(attributes) {
super(attributes);
this.gradClassName = attributes.gradClassName;
this.favInstructor = attributes.favInstructor;
}

standup(channel) {
console.log(`${this.name} announces to ${channel} @channel standup time`);
}

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

const john = new Student({
name: 'John',
age: 25,
location: 'Petersburg',
previousBackground: 'welder',
className: 'CS1',
favSubjects: ['javascript', 'databases', 'ui'],
});

const sam = new Instructor({
name: 'Sam',
age: 50,
location: 'Houston',
specialty: 'HTML',
favLanguage: 'Clojure',
catchPhrase: 'Get up with the get up',
});

const boe = new ProjectManager({
name: 'Boe',
age: 35,
location: 'Atlanta',
gradClassName: 'UX54',
favInstructor: 'Sam',
});

console.log(john);
console.log(sam);
console.log(boe);

sam.speak();
john.speak();
boe.speak();

john.listsSubjects();
john.PRAssignment('javascript-I');
john.sprintChallenge('javascript-II');

sam.demo('javascript-I');
sam.grade(john, 'javascript-IV');

boe.standup('slack-slack');
boe.debugsCode(john, 'javascript-IV');
95 changes: 95 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,98 @@ 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;
}

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

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

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

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