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
127 changes: 127 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,128 @@
// CODE here for your Lambda Classes
class Person {
constructor(attr) {
this.name = attr.name;
this.age = attr.age;
this.location = attr.location;
}
speak(){
return 'Hello my name is ' + this.name + ' I am from ' + this.location ;
}
}
class Instructor extends Person {
constructor(attr) {
super(attr);
this.specialty = attr.specialty;
this.favLanguage = attr.favLanguage;
this.catchPhrase= attr.catchPhrase;
}
demo(subject){
return "Today we are learning about " + subject;

}
grade (student, subject){
return this.student + "receives a perfect score on" + this.subject;
}
}
class Student extends Person{
constructor(attr){
super(attr);
this.previousBackground = attr.previousBackground;
this.className = attr.className;
this.favSubjects= attr.favSubjects;

}
listsSubjects(){
this.favSubjects.forEach(sub => console.log(sub));
//return this.favSubjects;
}
PRAssignments(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(attr){
super(attr);
this.gradClassName= attr.gradClassName;
this.favInstructor= attr.favInstructor;
}
standUp(channel){

return this.name + " announces to " + channel + ", @channel stand up time!";
}
debugsCode(subject){
return this.name + " debugs" + student.name + "code on" + subject;
}
}

const Subject= ['html', 'Python', 'JS', 'java', 'c' , 'c++'];
const Channel= ['Webpt9', 'Hired', 'announcements', 'bw_students_pt', 'ls1907_part_time'];

const Bobby = new Instructor({
name: 'Bobby',
location: 'Clifton',
age: 43,
favLanguage: 'Java',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});
const Joe = new Instructor({
name: 'Joe',
location: 'Tonia',
age: 28,
favLanguage: 'Python',
specialty: 'Back-end',
catchPhrase: `Never say never`
});
const Francine= new Student({
name: 'Francine',
location: 'Dalton',
age: 27,
favLanguage: 'JavaScript',
specialty: 'Design',
catchPhrase: ` Try and Try again`,
favSubjects: ['Html', 'CSS', 'JavaScript'],
previousBackground: 'Grounds Keeper',
ClassName: 'Webpt9'

});
const Kyle= new Student({
name: 'Kyle',
location: 'Scranton',
age: 29,
favLanguage: 'C++',
specialty: 'Backend',
catchPhrase: `Believe in yourself`,
favSubjects: ['Design', 'Python', 'JavaScript'],
previousBackground: 'Pre-school teacher',
ClassName: 'Webpt9'
});
const Chris = new ProjectManager({
name: 'Chris',
location: 'San Antonio ',
age: 40,
favLanguage: 'C',
specialty: 'Front-end',
catchPhrase: `Beauty is in the eye of the beholder`,
gradClassName: 'WB18',
favInstructor: 'Kennedy Smith'
});
const Martin= new ProjectManager({
name: 'Martin',
location: 'Detroit',
age: 32,
favLanguage: 'Java',
specialty: 'Back-end',
catchPhrase: `You can do anything you put your mind to`,
gradClassName: 'PhyWb18',
favInstructor: 'Atlanta Jackson'

});
console.log(Bobby.demo(Subject[5]));
console.log(Martin.speak());
console.log(Kyle.listsSubjects());
console.log(Francine.PRAssignments(Subject[2]));
console.log(Chris.standUp(Channel[3]));
148 changes: 147 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,149 @@ 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 (attr){
this.name = attr.name;
this.createdAt = attr.createdAt;
this.dimensions = attr.dimensions;
this.destroy = function (){
return this.name + ' was removed from the game.';
};
}
*/
class GameObject{
constructor (attr){
this.name = attr.name;
this.createdAt = attr.createdAt;
this.dimensions = attr.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
*/
/*function CharacterStats (attr){
this.healthPoints = attr.healthPoints;
//should inherit destroy() from GameObject's prototype
GameObject.call(this, attr);
this.takeDamage = function(){
return this.name + ' took damage';
};

}
CharacterStats.prototype = Object.create(GameObject.prototype);
*/
class CharacterStats extends GameObject{
constructor(attr){
super(attr);
this.healthPoints = attr.healthPoints;
}
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
*/

/* function Humanoid (attr){
this.team = attr.team;
this.weapons= attr.weapons;
this.language = attr.language;
CharacterStats.call(this, attr);
Humanoid.prototype.greet = function(){
return this.name + ' offers a greeting in ' + this.language
};
}
Humanoid.prototype = Object.create(CharacterStats.prototype);
*/
class Humanoid extends CharacterStats {
constructor(attr){
super(attr);
this.team = attr.team;
this.weapons= attr.weapons;
this.language = attr.language;
}
greet(){
return this.name + ' offers a greeting 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.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.