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

class Person {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

constructor(yeet) {
this.name = yeet.name;
this.age = yeet.age;
this.location = yeet.location;
this.gender = yeet.gender;

}
speak() {
return `Hello my name is ${this.name} , I am from ${this.location}`
}
}

class Instructor extends Person {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

constructor(instruct) {
super(instruct)
this.specialty = instruct.specialty;
this.favLanguage = instruct.favLanguage;
this.catchPhrase = instruct.catchPhrase;

}

demo(subject) {
return `Today we are learning about ${subject}`
}

grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}.`
}
}

class Student extends Person{
constructor(studentAttr){
super(studentAttr)
this.previousBackground = studentAttr.previousBackground;
this.classname = studentAttr.classname;
this.favSubjects = studentAttr.favSubjects;
}
listsSubjects() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be a method that logs out all of the student's favoriteSubjects one by one..

Given an array, which favSubjects is, how might you log each element of the array, one element at a time?

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

}


class ProjectManager extends Instructor {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

constructor(pmOptions) {
super(pmOptions);
this.gradClassName = pmOptions.gradClassName;
this.favInstructor = pmOptions.favInstructor;
}
standup(channel) {
return `${this.name} announces to ${channel}, @channel standy times!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}.`;
}
}



const fred = new Instructor({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to test the ProjectManager as well. And try using your own test data, it's better practice than using existing code.

name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});

const bill = new Student({
'name': 'bill',
'age': '1000000',
'location': 'Currently on the Sun',
'gender': 'Unknown',
'previousBackground': 'Unknown',
'className': 'CS1000000000000000',
'favSubjects': ['Python', 'Javascript', 'HTML/CSS']
});


console.log(fred);
console.log(bill);
console.log(bill);
84 changes: 60 additions & 24 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,75 @@
// 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) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
class GameObject {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}
destroy() {
return `Object was removed from the game.`;
}
}

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor(characterStatsOptions) {
super(characterStatsOptions)
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
}
takeDamage() {
return `${this.name} took damage.`;
}
}

function CharacterStats(characterStatsOptions) {
GameObject.call(this, characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
class Humanoid extends CharacterStats {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor(humanoidOptions) {
super(humanoidOptions)
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.language;
}
greet (){
return `${this.name} offers a greeting in ${this.language}.`;
}
}

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

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

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

Humanoid.prototype = Object.create(CharacterStats.prototype);
// function GameObject(options) {
// this.createdAt = options.createdAt;
// this.dimensions = options.dimensions;
// }

Humanoid.prototype.greet = function() {
return `${this.name} offers a greeting in ${this.language}.`;
};
// GameObject.prototype.destroy = function () {
// return `Object was removed from the game.`;
// };

// function CharacterStats(characterStatsOptions) {
// GameObject.call(this, characterStatsOptions);
// this.hp = characterStatsOptions.hp;
// this.name = characterStatsOptions.name;
// }

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

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

// function Humanoid(humanoidOptions) {
// CharacterStats.call(this, 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}.`;
// };

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