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


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


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

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


class projectManager extends Instructor {
constructor(projmanProps) {
super(projmanProps);
this.gradClassName = projmanProps.gradClassName;
this.favInstructor = projmanProps.favInstructor;
}
standUp(channel) {
console.log(`${this.name} announces to ${channel}, @channel standy times!`)
}
debugsCode(student, subject) {
console.log(`${this.name} debugs ${student.name}'s code on ${subject}`)
}
}


const bob = new Person({
name: "Bob",
age: 30,
location: "Iowa"
})

const megan = new Person({
name: "Megan",
age: 24,
location: "South Africa"
})


const josh = new Instructor({
name: "Josh Knell",
age: 30,
location: "Silicon Heaven, Utah",
specialty: "Front End",
favLanguage: "JavaScript",
catchPhrase: "Call me Uncle Josh",

})

const ben = new projectManager ({
name: "Ben Campbell",
age: 27,
location: "Heavenly Mexico",
specialty: "React Awesomeness",
favLanguage: "Spanish",
catchPhrase: "I'm heading to Denver to relax.",
gradClassName: "CS205",
favInstructor: "Ben Nelson"
})

const kelley = new Student ({
name: "Kelley",
age: 25,
location: "New Orleans",
previousBackground: "Secretary",
className: "CS11",
favSubjects: ["Anatomy", "Computer Science", "JavaScript"]
})

const ryan = new Instructor({
name: "Ryan",
age: 30,
location: "Somewhere, CA",
specialty: "codin'",
favLanguage: "JavaScript",
catchPhrase: "...I have a cool red beard?",

})

const perry = new projectManager ({
name: "perry",
age: 49,
location: "New York",
specialty: "HTML",
favLanguage: "English",
catchPhrase: "Don't get discouraged",
gradClassName: "CS20",
favInstructor: "Josh"
})

const melanie = new Student ({
name: "Melanie",
age: 19,
location: "Sacramento",
previousBackground: "Doctor",
className: "CS1",
favSubjects: ["Medicine, Forensics, Tech"]
})

62 changes: 44 additions & 18 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,65 @@
// 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;
}
destroy() {
return `${this.name} was removed from the game.`;
}
}

GameObject.prototype.destroy = function() {
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;
this.name = characterStatsOptions.name;
}
takeDamage() {
return `${this.name} took damage.`;
}
}

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

CharacterStats.prototype.takeDamage = function() {
return `${this.name} took damage.`;
};
// 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);
class Humanoid extends CharacterStats {
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}.`;
}
}

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

Humanoid.prototype.greet = function() {
return `${this.name} offers a greeting in ${this.language}.`;
};
// (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