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
133 changes: 133 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,134 @@
// CODE here for your Lambda Classes
class Person {
constructor(attributes){
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
}
speak(){
return `Hello my name is ${this.name}, I am from ${this.location}.`
}
}
const per1 = new Person({
name:"stan",
age:32,
location:"LA"
})
const per2 = new Person({
name:"dan",
age:23,
location:"Danville"
})


class Instructor extends Person{
constructor(instAttributes){
super(instAttributes);
this.speacialty = instAttributes.speacialty;
this.favLanguage = instAttributes.favLanguage;
this.catchPhrase = instAttributes.catchPhrase;
}
demo(subject){
return `Today we are learning about ${subject}`
}
grade(name, subject){
return `${name} receives a perfect score on ${subject}`
}
}
const inst1 = new Instructor({
name: 'Ben',
age: 42,
location: 'maine',
specialty: 'HTML',
favLanguage: 'JavaScript',
catchPhrase: 'Ode to Joy'
})

const inst2 = new Instructor({
name: 'Jane',
age: 33,
location: 'miami',
specialty: 'CSS',
favLanguage: 'Java',
catchPhrase: 'get to work'
})

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

const stu1 = new Student({
name: "jim",
age: 39,
location: "san francisco",
previousBackground: "sales",
className: "Web Intro",
favSubject: ["HTML", "CSS", "Java"],
})
const stu2 = new Student({
name: "mike",
age: 22,
location: "san jose",
previousBackground: "trucker",
className: "Web Dev",
favSubject: ["java", "python", "ruby"],
})

class Projectmanager extends Instructor{
constructor(pmAttribute){
super(pmAttribute);
this.gradClassName = pmAttribute.gradClassName;
this.favInstructor = pmAttribute.favInstructor;
}
standup(channel){
return `${this.name} announces to ${channel}, @channel standy times!​​​​​`
}
debugsCode(student, subject){
return `${this.name} debugs ${student.name}'s code on ${this.className}`
}
}
const pm1 = new Projectmanager ({
name: 'Ceasar',
age: 30,
location: 'chicago',
specialty: 'training',
favLanguage: 'JavaScript',
catchPhrase: 'Lets do this',
gradClassName: 'WebFunc1',
favInstructor: 'Brit'
});
const pm2 = new Projectmanager ({
name: 'Matt',
age: 60,
location: 'tampa bay',
specialty: 'python',
favLanguage: 'C++',
catchPhrase: 'Lets do this',
gradClassName: 'WebFunc2',
favInstructor: 'Brit'
});
console.log(per1.speak())
console.log(stu2.speak())
console.log(inst1.grade("carlos", "python"))
console.log(pm2.debugsCode(inst2, pm2.favLanguage))
console.log(pm1.standup("web23"))
console.log(stu2.listsSubjects())
console.log(stu2.PRAssignment(stu2.className))
console.log(stu1.sprintChallenge("web design"))
console.log(pm2.speak())

console.log(stu2.standup("IOS"))
119 changes: 118 additions & 1 deletion assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,123 @@ 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.
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(attributes){
this.createdAt = attributes.createdAt;
this.dimensions = attributes.dimensions;
this.name = attributes.name;
}
destroy(){
return `${this.name} was removed from the game.`
}
}

class CharacterStats extends GameObject{
constructor(childAttributes){
super(childAttributes);
this.healthPoints = childAttributes.healthPoints;
}
takeDamage(){
return `${this.name} took damage.`
}
// CharacterStats.prototype = Object.create(GameObject.prototype)//Child.prototype = Object.create(Person.prototype);
}
/*
=== 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(chAttributes){
super(chAttributes);
this.weapons = chAttributes.weapons;
this.language = chAttributes.language;
this.team = chAttributes.team

}
// Humanoid.prototype = Object.create(CharacterStats.prototype)

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.