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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ This challenge focuses on classes in JavaScript using the new `class` keyword.

**Follow these steps to set up and work on your project:**

* [ ] Create a forked copy of this project.
* [ ] Add your project manager as collaborator on Github.
* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!).
* [ ] Create a new branch: git checkout -b `<firstName-lastName>`.
* [ ] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
* [ ] Push commits: git push origin `<firstName-lastName>`.
* [x ] Create a forked copy of this project.
* [ x] Add your project manager as collaborator on Github.
* [ x] Clone your OWN version of the repository (Not Lambda's by mistake!).
* [x ] Create a new branch: git checkout -b `<firstName-lastName>`.
* [x ] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
* [ x] Push commits: git push origin `<firstName-lastName>`.

**Follow these steps for completing your project.**

* [ ] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
* [ ] Add your project manager as a reviewer on the pull-request
* [ ] Your project manager will count the project as complete by merging the branch back into master.
* [x ] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
* [ x] Add your project manager as a reviewer on the pull-request
* [ x] Your project manager will count the project as complete by merging the branch back into master.

## Assignment Description

Expand Down
125 changes: 124 additions & 1 deletion assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,124 @@
// CODE here for your Lambda Classes
class Person{
constructor(attr){
this.name = attr.name;
this.age = attr.age;
this.location = attr.location;
}
phrase(){
console.log(`Hello my name is ${this.name}, I am from ${this.location}`);
}
}

class Instructor extends Person{
constructor(attrInstruc){
super(attrInstruc);
this.specialty = attrInstruc.specialty;
this.favLanguage = attrInstruc.favLanguage;
this.catchPhrase = attrInstruc.catchPhrase;
}
demo(subject){
console.log(`Today, we are learning about ${subject}!`);
}
grade(student,subject){
console.log(`Did you know, ${student} received a perfect score on ${subject}?`);
}
}


class Student extends Person{
constructor(attrStud){
super(attrStud);
this.previousBackground = attrStud.previousBackground;
this.className = attrStud.className;
this.listsSubjects = attrStud.listsSubjects;
this.subject = attrStud.subject;
}
PRAssignment(){
return `${this.name} has submitted a PR for ${this.subject}!`;
}
sprintChallenge(){
return `${this.name} has begun sprint challenge on ${this.subject}`;
}
}

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




const instruct = new Instructor({
//from person
name: 'Vijay',
age: 39,
location: 'New York',
//from instructor
specialty: 'Ribbon Dancing',
favLanguage: 'Sign',
catchPhrase: 'Can you sign with all the colors of the wind?',
});



const student = new Student({
//from Person
name:'Jake',
age:20,
location:'Arizona',
//from Instructor
previousBackground:'dumpster diver',
className:'Home Economics',
listsSubjects: {
sub1:'where is the paper map',
sub2:'is is supposed to be a cold soup',
sub3:'hatchet sharpening',
},
subject:'HTML'
});

const projmgr = new ProjectManager({
//from Person
name:'Roman',
age:36,
location:'Florida',
//from Instructor
previousBackground:'Uber driver',
className:'Basic things',
listsSubjects: {
sub1:'origami for masters',
sub2:'good cursive',
sub3:'go outside and play a sport',
},
//from Student
gradClassName:'bumblebees',
favInstructor:'Vijay',
});




console.log(instruct.name);
console.log(instruct.catchPhrase);
console.log(student.location);
console.log(student.listsSubjects);
console.log(projmgr.demo('basket weaving'));
console.log(instruct.grade(student.name,'geography'));
console.log(student.PRAssignment());
console.log(projmgr.debugsCode());
console.log(student.sprintChallenge());
console.log(projmgr.standUp('bumblebeeChamps!!'));




97 changes: 97 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,100 @@ 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.

*/
class GameObject {
constructor(attrG){
this.createdAt = attrG.createdAt;
this.name = attrG.name;
this.dimensions = attrG.dimensions
}
destroy(){
return `${this.name} was removed from the game.`;
}
}

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

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

//The characters to console.log

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.