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
47 changes: 46 additions & 1 deletion assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
// CODE here for your Lambda Classes
class Instructors 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(subject){
console.log(`${this.name} receives a perfect score on ${subject}`)
}
}

class Student extends Person{
constructor (attributes){
super(attributes);
this.previousBackground = attributes.previousBackground;
this.className = attributes.className;
this.favSubject = attributes.favSubject;
}
listsSubjects(){
console.log(this.favSubject)
}
PRAssignment(subject){
console.log(`${Student.name} has submitted a PR for ${subject}.`)
}
sprintChallenge(subject){
console.log(`${Student.name} has begun sprint challenge on ${subject}.`)
}
}

class PM extends Instructors{
constructor (attributes){
super(attributes);
this.gradClassName = attributes.gradClassName;
this.favInstructor = attributes.favInstructor;
}
standUp(name){
console.log(`${name} announces to channel, @Channel stand times!`)
}
debugsCode(name,studentName,subject){
console.log(`${name}debugs ${studentName}'s code on ${subject}`)
}
}
119 changes: 119 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,126 @@
Prototype Refactor

1. Copy and paste your code or the solution from yesterday
function GameObject(attributes){
this.createdAt = attributes.createdAt;
this.dimensions = attributes.dimensions;
this.name = attributes.name;
GameObject.prototype.destroy = function(){
return `${this.name} was removed from the game.`
}
}

function CharacterStats(attributes){
GameObject.call(this, attributes);
this.healthPoints = attributes.healthPoints;
this.name = attributes.name;
}
CharacterStats.prototype = Object.create(GameObject.prototype)

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

function Humanoid(attributes){
CharacterStats.call(this,attributes);
this.team = attributes.team;
this.weapons = attributes.weapons;
this.language = attributes.language;
}
Humanoid.prototype = Object.create(CharacterStats.prototype);

Humanoid.prototype.greet = function(){
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.

*/

class GameObject{
constructor (attributes){
this.createdAt = attributes.createdAt;
this.dimensions = attributes.dimensions;
this.name = attributes.name;
}
destroy(){
return `${this.name} was removed from the game.`
}
}

class CharacterStats extends GameObject{
constructor (attributes){
super(attributes);
this.healthPoints = attributes.healthPoints;
this.name = attributes.name;
}
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}`)
}
}

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