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
88 changes: 88 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,89 @@
// CODE here for your Lambda Classes
class people{
constructor(params){
this.age=params.age;
this.name=params.name;
this.location=params.location;
this.gender=params.gender;
}
speak(){
return ("Hello, my name is "+this.name+", and I'm from "+this.location);
}
}
class instructor extends people{
constructor(params){
super(params);
this.specialty=params.specialty;
this.favLang=params.favLang;
this.chatchPhrase=params.catchPhrase;
}
demo(subject){
return("Yo, yo, yo, today we're learning about "+subject+" ya'll!")
}
grade(student,subject){
return(student.name+" is a horrible dissapointment, and failed at "+subject)
}
}
class student extends people{
constructor(params){
super(params);
this.previousBackground=params.previousBackground;
this.className=params.className;
this.favSubjects=params.favSubjects;
}
listSubjects(){
function myFunc(value){
console.log(value);
}
this.favSubjects.forEach(myFunc);
}
}
class projectManager extends instructor{
constructor(params){
super(params);
this.gradClassName=params.gradClassName;
this.favInstructor=params.favInstructor;
}
standUp(chan){
console.log(`${this.name} announces to ${chan}, @channel standy times!`)
}
debugsCode(student,subject){
console.log(this.name+" laughs at "+student.name+" for screwing up at "+subject)
}
}

const fred = new instructor({
"gender": "M",
"age": 35,
"name": "Fred",
"location": "bedrock",
"specialty": "Rock.os",
"favLang": "club++",
"catchPhrase": "Yabba Dabba Doo!",
});
const David = new student({
"gender": "M",
"age": 21,
"name": "David",
"location": "OH",
"previousBackground": "highschool student",
"className": "cs11",
"favSubjects": ['math','coding','history','tigers'],
});
const Josh = new projectManager({
"gender": "M",
"age": '30-ish',
"name": "Josh",
"location": "the moon",
"specialty": "everything",
"favLang": "English",
"catchPhrase": "Yabba Dabba Doo!",
"gradClassName": "cs4",
"favInstructor": "himself",
});


console.log(fred.speak());
console.log(fred.grade(David, 'science'));
David.listSubjects();
Josh.standUp('our channel');
39 changes: 19 additions & 20 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,38 @@
// 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() {
};
greet() {
return `${this.name} offers a greeting in ${this.language}.`;
};
};
}

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