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
124 changes: 124 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,125 @@
// CODE here for your Lambda Classes
class Person{
constructor(person){
this.newName = person.name;
this.newAge = person.age;
this.newLocation = person.location;
}
speak(){
return console.log(`Hello my name is ${this.newName}, I am from ${this.newLocation}`);
}
}

class Instructor extends Person{
constructor(instructor){
super(instructor);
this.newSpecialty = instructor.specialty;
this.newFavLanguage = instructor.favLanguage;
this.newCatchPhrase = instructor.catchPhrase;
}
demo(subject){
return console.log(`Today we are learning about ${subject}`);
}
grade(student, subject){
return console.log(`${student.newName} receives a perfect score on ${subject}`);
}
}

class Student extends Person{
constructor(student){
super(student);
this.newPreviousBackground = student.previousBackground;
this.newClassName = student.className;
this.newFavSubjects = student.favSubjects;
}
listsSubjects(){
console.log(this.newFavSubjects.toString());
}
PRAssignment(subject){
return console.log(`${this.newName} has submitted a PR for ${subject}`);
}
sprintChallenge(subject){
return console.log(`${this.newName} has begun sprint challenge on ${subject}`);
}
}

class ProjectManager extends Instructor{
constructor(projectmanager){
super(projectmanager);
this.newGradClassName = projectmanager.gradClassName;
this.newFavInstructor = projectmanager.favInstructor;
}
standUp(channel){
return console.log(`${this.newName} announces to ${channel}, @channel standy times!`);
}
debugsCode(student, subject){
return console.log(`${this.newName} debugs ${student.newName}'s code on ${subject}`);
}
}

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

const richard = new Instructor({
name: 'Richard',
location: 'Little Rock',
age: 33,
favLanguage: 'CSS',
specialty: 'Front-end',
catchPhrase: `Be there or be square`
});

const matt = new Student({
name: 'Matt',
location: 'Santa Barbara',
age: 27,
previousBackground: 'Welder',
className: 'WEB25',
favSubjects: ['Python', 'React', 'Javascript']
});

const joey = new Student({
name: 'Joey',
location: 'Portland',
age: 25,
previousBackground: 'Information Technology',
className: 'WEB25',
favSubjects: ['HTML', 'CSS', 'Javascript']
});

const drew = new ProjectManager({
name: 'Drew',
location: 'Scotts Valley',
age: 30,
favLanguage: 'Python',
specialty: 'Back-end',
catchPhrase: `When life gives you lemons, make lemonade`,
gradClassName: 'WEB13',
favInstructor: 'Britt'
});

const nick = new ProjectManager({
name: 'Nick',
location: 'Seattle',
age: 36,
favLanguage: 'Java',
specialty: 'Back-end',
catchPhrase: `Don't get ahead of yourself`,
gradClassName: 'WEB15',
favInstructor: 'Britt'
});

nick.speak();
fred.demo("React");
richard.grade(joey, "HTML");
matt.listsSubjects();
matt.PRAssignment("React");
joey.sprintChallenge("Python");
drew.standUp("#web25");
nick.debugsCode(joey, "CSS")
104 changes: 104 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,107 @@ 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(foobar) {
this.createdAt = foobar.createdAt;
this.name = foobar.name;
this.dimensions = foobar.dimensions;
}
destroy(){
return this.name + " was removed from the game.";
}
}


class CharacterStats extends GameObject{
constructor(item){
super(item);
this.healthPoints = item.healthPoints;
}
takeDamage(){
return this.name + " took damage.";
}
}

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