Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
56c2ff3
Pasted code from previous project
Insurikai Sep 19, 2019
299d786
Refactored GameObject
Insurikai Sep 19, 2019
f3a63ff
Refactored CharacterStats
Insurikai Sep 19, 2019
d73131f
Refactored Humanoid
Insurikai Sep 19, 2019
bf973e4
Commented out old code and pasted in test code
Insurikai Sep 19, 2019
41f7da4
base infor for lambda classes
Insurikai Sep 19, 2019
dd5be4b
base constructors
Insurikai Sep 19, 2019
83054cf
person constructor finished
Insurikai Sep 19, 2019
816ce59
person speak method finished
Insurikai Sep 19, 2019
da2080e
Student constructor finished
Insurikai Sep 19, 2019
e6056b0
Student method templates
Insurikai Sep 19, 2019
61beee7
Student listSubjects finished
Insurikai Sep 19, 2019
01c681f
Student PRAssignment finished
Insurikai Sep 19, 2019
4823e8a
Student methods finished
Insurikai Sep 19, 2019
d08b058
Instructor constructor finished
Insurikai Sep 19, 2019
24197da
Instructor method templates
Insurikai Sep 19, 2019
a5da3de
Instructor demo moved and finished
Insurikai Sep 19, 2019
5c92fc9
Instructor grade finished
Insurikai Sep 19, 2019
16d08e8
ProjectManager constructor finished
Insurikai Sep 19, 2019
cd44413
ProjectManager method templates finished
Insurikai Sep 19, 2019
193d5e1
ProjectManager standUp finished
Insurikai Sep 19, 2019
5667949
ProjectManager debugsCode finished
Insurikai Sep 19, 2019
a483cf2
class templates finished
Insurikai Sep 19, 2019
fa18fd4
class templates duplicated
Insurikai Sep 19, 2019
a786c82
classes edited
Insurikai Sep 19, 2019
dfb9275
testing templates
Insurikai Sep 19, 2019
7d3a169
testing complete
Insurikai Sep 19, 2019
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ 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.**

Expand Down
113 changes: 113 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,114 @@
// CODE here for your Lambda Classes

class Person{
constructor(args){
this.name = args.name;
this.age = args.age;
this.location = args.location;
}
speak(){
return `Hello my name is ${this.name}, I am from ${this.location}`
}
}
class Student extends Person{
constructor(args){
super(args);
this.previousBackground = args.previousBackground;
this.className = args.className;
this.favSubjects = args.favSubjects;
}
listsSubjects(){
this.favSubjects.forEach(element => console.log(element));
}
PRAssignment(subject){
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject){
return `${this.name} has begun sprint challenge on ${subject}`
}

}
class Instructor extends Person{
constructor(args){
super(args);
this.specialty = args.specialty;
this.favLanguage = args.favLanguage;
this.catchPhrase = args.catchPhrase;
}
demo(subject){ return `Today we are learning about ${subject}`; }
grade(student, subject){ return `${student.name} receives a perfect score on ${subject}`; }
}
class ProjectManager extends Instructor{
constructor(args){
super(args);
this.gradClassName = args.gradClassName;
this.favInstructor = args.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 stewart = new Student({
name: 'Stewart',
location: 'New Hampshire',
age: 37,
favSubjects: ["Maths", "Social Studies"],
className: "Web24",
previousBackground: "Bartendor"
});
const amanda = new Student({
name: 'Amanda',
location: 'Myrtle Beach',
age: 20,
favSubjects: ["Arts", "Language Arts", "Digital Design", "Photography"],
className: "Data Science",
previousBackground: "Wedding Photographer"
});

const sam = new Instructor({
name: 'Sam',
location: 'Inglewood',
age: 27,
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Perfect.`
});
const fredrick = new Instructor({
name: 'Fredrick',
location: 'Branson',
age: 22,
favLanguage: 'C#',
specialty: 'Full Stack',
catchPhrase: `Why isn't this working?`
});

const sabrina = new ProjectManager({
name: 'Sabrina',
location: 'Westchester',
age: 33,
favLanguage: 'MySQL',
specialty: 'Back-end',
catchPhrase: `Not like that!`,
gradClassName: "Web24",
favInstructor: "Daniel"
});
const gonzo = new ProjectManager({
name: 'Gonz the Great',
location: '404 Location Unknown',
age: 999,
favLanguage: 'All of them',
specialty: 'Everything',
catchPhrase: `Witness my GREATNESS.`,
gradClassName: "Web99",
favInstructor: "Gonzo"
});

console.log(stewart.sprintChallenge(stewart.favSubjects[1]));
console.log(amanda.previousBackground);
console.log(sam.catchPhrase);
console.log(fredrick.demo("Javascript IV"));
console.log(sabrina.debugsCode(stewart, "PHP Fundamentals"));
console.log(gonzo.grade(amanda, stewart.favSubjects[0]));
console.log(gonzo.speak());
console.log(gonzo.standUp('Web99'));
125 changes: 125 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,128 @@ 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.

*/

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

function CharacterStats(obj) {
GameObject.call(this, obj);
this.healthPoints = obj.healthPoints;
}
CharacterStats.prototype = Object.create(GameObject.prototype);
CharacterStats.prototype.takeDamage = function () {
return `${this.name} took damage.`
}

function Humanoid(obj) {
CharacterStats.call(this, obj);
this.team = obj.team;
this.weapons = obj.weapons;
this.language = obj.language;
}
Humanoid.prototype = Object.create(CharacterStats.prototype);
Humanoid.prototype.greet = function () {
return `${this.name} offers a greeting in ${this.language}.`
} */

/************* Refactored ************/

class GameObject{
constructor(args){
this.createdAt = args.createdAt;
this.name = args.name;
this.dimensions = args.dimensions;
}
destroy(){
return `${this.name} was removed from the game.`;
};
}
class CharacterStats extends GameObject {
constructor(args){
super(args);
this.healthPoints = args.healthPoints;
}
takeDamage() {
return `${this.name} took damage.`
}
}
class Humanoid extends CharacterStats{
constructor(args){
super(args);
this.team = args.team;
this.weapons = args.weapons;
this.language = args.language;
}
greet() {
return `${this.name} offers a greeting in ${this.language}.`
}
}

/****** Test Code *********/

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.