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

class Instructor extends Person{
constructor(args){
super(args);
this.specialty = args.specialty;
this.favLanguage = args.favLanguage;
this.catchPhrase = args.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(args){
super(args);
this.previousBackground = args.previousBackground;
this.className = args.className;
this.favSubjects = args.favSubjects;
}
listsSubjects(){
this.favSubjects.forEach((subject) => {
console.log(subject);
});
}
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 {
constructor(args){
super(args);
this.gradClassName = args.gradClassName;
this.favInstructor = args.favInstructor;
}
standUp(channel){
console.log(`${this.name} announces to ${channel}, @channel standup times`);
}
debugsCode(student,subject){
console.log(`${this.name} debugs ${student.name}'s code on ${subject}`);
}
}

let callum = new ProjectManager({
name: "Callum",
age: 25,
gender: "M",
location: "San Francisco",
specialty: "React",
favLanguage: "JavaScript",
catchPhrase: "Good Job",
gradClassName: "CS11",
favInstructor: "Josh"
});

let tom = new Student({
name: "Tom",
age: 21,
gender: "M",
location: "wisconsin"
});

console.log(callum.debugsCode(tom,"math"));
47 changes: 40 additions & 7 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
// 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) {
/*function GameObject(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}*/

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

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

function CharacterStats(characterStatsOptions) {
/*function CharacterStats(characterStatsOptions) {
GameObject.call(this, characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
Expand All @@ -21,9 +31,20 @@ CharacterStats.prototype = Object.create(GameObject.prototype);

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

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

function Humanoid(humanoidOptions) {
/*function Humanoid(humanoidOptions) {
CharacterStats.call(this, humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
Expand All @@ -34,7 +55,19 @@ Humanoid.prototype = Object.create(CharacterStats.prototype);

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

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

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