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

class Instructor extends Person {
constructor(instructorInfo){
super(instructorInfo);
this.speacialty= instructorInfo.speacialty;
this.favLanguage= instructorInfo.favLanguage;
this.catchPhrase= instructorInfo.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(studentInfo){
super(studentInfo);
this.previousBackground =studentInfo.previousBackground;
this.className= studentInfo.className;
this.favSubjects= studentInfo.favSubjects;
}
listsSubjects(){
console.log(`${this.favSubjects}`);
}
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 Pms extends Instructor{
constructor(pmInfo){
super(pmInfo);
this.gradClassName= pmInfo.gradClassName;
this.favInstructor= pmInfo.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}.`);

}
}


const Josh= new Instructor({
name:'Josh',
gender:'male',
favLanguage:'JavaScript',
catchPhrase: `Don't forget the homies.`
});

const Justin= new Pms({
name:'Justin',
gender:'male',
favInstructor:'Josh'
});

const Alex= new Student ({
name: 'Alex',
gender:'male',
age: 25,
className:'cs11'
});
38 changes: 19 additions & 19 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
// 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() {
return `${this.name} offers a greeting in ${this.language}.`;
};
greet(){
return `${this.name} offers a greeting in ${this.language}`;
}
}

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