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
Binary file added .DS_Store
Binary file not shown.
156 changes: 155 additions & 1 deletion assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,155 @@
// CODE here for your Lambda Classes

// Person class

class Person {
constructor(attrs) {
this.name = attrs.name;
this.age = attrs.age;
this.location = attrs.location;
}

speak() {
console.log(`Hello, my name is ${this.name}, I am from ${this.location}`);
}
}


// Instructor class

class Instructor extends Person {
constructor(instAttrs) {
super(instAttrs);
this.specialty = instAttrs.specialty;
this.favLanguage = instAttrs.favLanguage;
this.catchPhrase = instAttrs.catchPhrase;
}

demo(subject) {
console.log(`Today we are learning about ${subject}`);
}

grade(student, subject) {
console.log(`${student} receives a perfect score on ${subject}`)
}
}


// Student class

class Student extends Person {
constructor(stuAttrs) {
super(stuAttrs);
this.previousBackground = stuAttrs.previousBackground;
this.className = stuAttrs.className;
this.favSubjects = [stuAttrs.favSubjects];
}

listsSubjects() {
console.log(`${this.favSubjects}`);
}

PRAssignment() {
console.log(`${this.name} has submitted a PR for ${this.subject}`);
}

sprintChallenge() {
console.log(`${this.name} has begun sprint challenge for ${this.subject}`);
}
}


// ProjectManager class

class ProjectManager extends Instructor {
constructor(pmAttrs) {
super(pmAttrs);
this.gradClassName = pmAttrs.gradClassName;
this.favInstructor = pmAttrs.favInstructor;
}

standUp(channel) {
console.log(`${this.name} announces to ${channel} @channel Standup Time!`);
}

debugsCode(student, subject) {
console.log(`${this.name} debugs ${student.name}'s code on ${student.favSubjects}`);
}
}

// Instructor objects

const dan = new Instructor({
name: 'Dan',
age: 32,
location: 'Colorado',
specialty: 'Redux',
favLanguage: 'JavaScript',
catchPhrase: 'Rosie, no!',
})


const josh = new Instructor({
name: 'Josh',
age: 32,
location: 'Utah',
specialty: 'Redux',
favLanguage: 'JavaScript',
catchPhrase: 'Banjo time!',
})


// Student objects

const emily = new Student({
name: 'Emily',
age: 32,
location: 'Illinois',
previousBackground: 'Teacher',
className: 'Web 21',
favSubjects: 'Logic',
})

const marcus = new Student({
name: 'Marcus',
age: 32,
location: 'Illinois',
previousBackground: 'Teacher',
className: 'Web 21',
favSubjects: ['Logic', 'Syntax', 'Language'],
})


// ProjectManager objects

const nick = new ProjectManager({
name: 'Nick',
age: 32,
location: 'New Mexico',
specialty: 'Redux',
favLanguage: 'JavaScript',
catchPhrase: 'Listen up!',
gradClassName: 'Web 19',
favInstructor: 'Dan',
})

const jose = new ProjectManager({
name: 'Jose',
age: 32,
location: 'Illinois',
specialty: 'Redux',
favLanguage: 'JavaScript',
catchPhrase: 'Listen up!',
gradClassName: 'Web 19',
favInstructor: 'Dan',
})


// console.log() tests

console.log(dan.name);
console.log(dan.catchPhrase);
console.log(emily.location);
console.log(marcus.listsSubjects())
console.log(nick.catchPhrase);
console.log(nick.standUp("Nick_Ballenger's_Channel"));
console.log(nick.debugsCode(emily));
126 changes: 125 additions & 1 deletion assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*

Prototype Refactor

Expand All @@ -7,3 +7,127 @@ Prototype Refactor
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.

*/

/*
=== GameObject ===
* createdAt
* name
* dimensions (These represent the character's size in the video game)
* destroy() // prototype method that returns: `${this.name} was removed from the game.`
*/

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

class GameObjects {
constructor(attrs) {
this.createdAt = attrs.createdAt;
this.name = attrs.name;
this.dimensions = attrs.dimensions;
}

destroy() {
return `${this.name} was removed from the game.`
}
}

class CharacterStats extends GameObjects {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to keep confusion down you can actually use the same naming convention across all the super/constructors if you want to (you could go with attrs/props across the board if you wanted to)

constructor(attrs1) {
super(attrs1);
this.healthPoints = attrs1.healthPoints;
}

takeDamage() {
return `${this.name} took damamge.`
}
}

class Humanoid extends CharacterStats {
constructor(attrs2) {
super(attrs2);
this.team = attrs2.team;
this.weapons = attrs2.weapons;
this.language = attrs2.language;
}

greet () {
return `${this.name} offers a greeting in ${this.language}.`
}
}

// Test you work by un-commenting these 3 objects and the list of console logs below:


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

console.log(mage.createdAt); // Today's date
console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
console.log(swordsman.healthPoints); // 15
console.log(mage.name); // Bruce
console.log(swordsman.team); // The Round Table
console.log(mage.weapons); // Staff of Shamalama
console.log(archer.language); // Elvish
console.log(archer.greet()); // Lilith offers a greeting in Elvish.
console.log(mage.takeDamage()); // Bruce took damage.
console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.


// Stretch task:
// * Create Villain and Hero constructor functions that inherit from the Humanoid constructor function.
// * Give the Hero and Villains different methods that could be used to remove health points from objects which could result in destruction if health gets to 0 or drops below 0;
// * Create two new objects, one a villain and one a hero and fight it out with methods!