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

class Instructor extends Person{
constructor(props){
super(props);
this.specialty = props.specialty;
this.favLanguage = props.favLanguage;
this.catchPhrase = props.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(props){
super(props);
this.previousBackground = props.previousBackground;
this.className = props.className;
this.favSubjects = props.favSubjects;
}
listsSubjects(){
for(let i = 0; i < this.favSubjects.length; i++){console.log(this.favSubjects[i]);}
}
PRAssignment(sub){
return `${this.name} has submitted a PR for ${sub}.`
}
sprintChallenge(sub){
return `${this.name} has begun sprint challenge on ${sub};`
}
}

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

const Ryan = new Person({
name: 'Ryan',
location: 'Atlanta',
age: 33,
gender: 'male',
});
const Jones = new Person({
name: 'Jones',
location: 'Atlanta',
age: 29,
gender: 'male',
});
const Quinn = new Instructor ({
name: 'Quinn',
location: 'Atlanta',
age: 33,
gender: 'male',
specialty: 'Defense',
favLanguage: 'python',
catchPhrase: 'defense almost wins championships...fn patriots'
});
const Manuel = new Instructor ({
name: 'Manuel',
location: 'Atlanta',
age: 39,
gender: 'male',
specialty: 'Defense',
favLanguage: 'javascript',
catchPhrase: 'dont come in this danger zone half-steppin'
});
const Freeman = new Student ({
name: 'Freeman',
location: 'Atlanta',
age: 26,
gender: 'male',
specialty: 'runnin that rock',
favLanguage: '.Net',
catchPhrase: 'just give me the ball and watch me work',
previousBackground: 'worked at a funeral home',
className: 'webpt4',
favSubjects: ['mobile', 'networking', 'linux',]
});
const Sanu = new Student ({
name: 'Sanu',
location: 'Atlanta',
age: 29,
gender: 'male',
specialty: 'going to get it',
favLanguage: 'C',
catchPhrase: 'im just gonna go get it, stop me',
previousBackground: 'orange and black pack',
className: 'webpt4',
favSubjects: ['hardware', 'arduino', 'raspberry pi',]
});
const Neal = new ProjectManagers ({
name: 'Neal',
location: 'Atlanta',
age: 23,
gender: 'male',
specialty: 'making people feel it in the worst way',
favLanguage: 'Java',
catchPhrase: "everytime you see me it'll be from your back",
previousBackground: 'the swamp land',
className: 'webpt4',
favSubjects: ['ruby', 'sql', 'networking',],
gradClassName: 'Gators',
favInstructor: 'Quinn'
});
const DJones = new ProjectManagers ({
name: 'DJones',
location: 'Atlanta',
age: 24,
gender: 'male',
specialty: 'all things lb',
favLanguage: 'Android',
catchPhrase: "fillin holes and strikin fear in nick foles",
previousBackground: 'tiger country',
className: 'webpt4',
favSubjects: ['html', 'css', 'react',],
gradClassName: 'Tigers',
favInstructor: 'Quinn'
});
console.log(Ryan);
console.log(Jones.speak());
console.log(Quinn.catchPhrase);
console.log(Manuel.speak());
console.log(Freeman.listsSubjects());
console.log(Sanu.PRAssignment('JS-IV'));
console.log(Neal.catchPhrase);
console.log(DJones.debugsCode(Sanu.name, 'JS-IV'));


136 changes: 136 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,139 @@ 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
* dimensions (These represent the character's size in the video game)
* destroy() // prototype method -> returns the string: 'Object was removed from the game.'
*/


class GameObject{
constructor(attributes){
this.createdAt = attributes.createdAt;
this.dimensions = attributes.dimensions;
}

destroy(){
return `Object was removed from the game.`;
}
}



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


class CharacterStats extends GameObject{
//GameObject.call(this, characterbutes);
constructor(attributes){
super(attributes);
this.healthPoints = attributes.healthPoints;
this.name = attributes.name;
}
takeDamage(){
return `${this.name} took 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(attributes){
super(attributes);
this.team = attributes.team;
this.weapons = attributes.weapons;
this.language = attributes.language;
}

great(){
return `${this.team} says hello in ${this.language}`;
}
}

/*
* Inheritance chain: GameObject -> CharacterStats -> Humanoid
* Instances of Humanoid should have all of the same properties as CharacterStats and GameObject.
* Instances of CharacterStats should have all of the same properties as GameObject.
*/

// 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.great()); // Lilith offers a greeting in Elvish.
console.log(mage.takeDamage()); // Bruce took damage.
console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.