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
77 changes: 77 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
// CODE here for your Lambda Classes

class Person{
constructor(attributes){
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
this.gender = attributes.gender;
}
speak(){
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}


class Instructor extends Person{
constructor(attributes2){
super(attributes2);
this.specialty = attributes2.specialty;
this.favLanguage = attributes2.favLanguage;
this.catchPhrase = attributes2.catchPhrase;
}
demo(){
return `Today we are learning about {subject}`;
}
grade(){
return `{student.name} receives a perfect score on {subject}`;
}
}

class Student extends Instructor{
constructor(attributes3){
super(attributes3);
this.previousBackground = attributes3.previousBackground;
this.className = attributes3.className;
this.favSubjects = attributes3.favSubjects;
}
listsSubjects(){
return `${this.favSubjects}`;
}
PRAassignment(){
return `${this.name} has submitted a PR for ${this.favSubjects}`;
}
sprintChallenge(){
return `${this.name} has begun spring challenge ${this.favSubjects}`;
}
}

class ProjectManager extends Student{
constructor(attributes4){
super(attributes4);
this.gradClassName = attributes4.gradClassName;
this.favInstructor = attributes4.favInstructor;
}
standUp(){
return `${this.name} announces to {channel} @channel standy times!`;
}
debugsCode(){
return `${this.name} debugs ${this.Student.name}'s code on ${this.favSubjects}`;

}
}

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

console.log(fred.speak());
console.log(fred.demo());
console.log(fred.grade());
console.log()
console.log()
38 changes: 19 additions & 19 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
// Today 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.

function GameObject(options) {
class GameObject {
constructor(options){
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}

GameObject.prototype.destroy = function() {
destroy(){
return `Object was removed from the game.`;
};
}
}

function CharacterStats(characterStatsOptions) {
GameObject.call(this, characterStatsOptions);

class CharacterStats extends GameObject{
constructor(characterStatsOptions){
super(characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
}

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

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

function Humanoid(humanoidOptions) {
CharacterStats.call(this, humanoidOptions);
class Humanoid extends CharacterStats {
constructor(humanoidOptions){
super(humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.language;
}

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

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

const mage = new Humanoid({
createdAt: new Date(),
Expand Down