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

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

}

class Student extends Person {
constructor(studOptions) {
super(studOptions);
this.previousBackground = studOptions.previousBackground;
this.className = studOptions.className;
this.favSubjects = studOptions.favSubjects; //an array
}
listsSubjects() {
return `${this.favSubjects}`
}
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(pmOptions) {
super(pmOptions);
this.gradClassName = pmOptions.gradClassName;
this.favInstructor = pmOptions.favInstructor;
}
standup(channel) {
return `${this.name} announces to ${channel}, @channel standy times!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}.`
}
}

const john = new Instructor({
'name': 'John',
'age': '32',
'location': 'San Francisco',
'gender': 'Male',
'specialty': 'UI/UX',
'favLanguage': 'Javascript',
'catchPhrase': 'Script it right',
'pronoun': 'his'
});


const jane = new ProjectManager({
'name': 'Jane',
'age': '28',
'location': 'Oakland',
'gender': 'Female',
'specialty': 'People Management',
'favLanguage': 'Python',
'catchPhrase': 'keep the people happy',
'gradClassName': 'web19',
'favInstructor': 'Cool Dude',
'pronoun': 'her'
});


const tim = new Student({
'name': 'Tim',
'age': '21',
'location': 'Reno',
'gender': 'Male',
'previousBackground': 'worked at grocery store',
'className': 'Web22',
'favSubjects': ['Science', 'Math', 'English'],
'pronoun': 'his'
});


104 changes: 104 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,109 @@ Prototype Refactor
1. Copy and paste your code or the solution from yesterday

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.
*/
class GameObject {
constructor(obj){
this.createdAt = obj.createdAt;
this.name = obj.name;
this.dimensions = obj.dimensions;
}
destroy() {return `${this.name} was removed from the game.`;}
}

/*
=== CharacterStats ===
* healthPoints
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
* should inherit destroy() from GameObject's prototype
*/

class CharacterStats extends GameObject {
constructor(obj){
super(obj);
this.healthPoints = obj.healthPoints;
}
takeDamage() {return `${this.name} takes damage.`}
}

/*
=== Humanoid (Having an appearance or character resembling that of a human.) ===
* team
* weapons
* language
* greet() // prototype method -> returns the string '<object name> offers a greeting in <object language>.'
* should inherit destroy() from GameObject through CharacterStats
* should inherit takeDamage() from CharacterStats
*/

class Humanoid extends CharacterStats {
constructor(obj){
super(obj);
this.team = obj.team;
this.weapons = obj.weapons;
this.language = obj.language;
}
greet() {return `${this.name} offers a greeting in ${this.language}.`}
}



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.