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

class Instructor extends Person{
constructor(att){
super(att)
this.specialty = att.specialty;
this.favLanguage = att.favLanguage;
this.catchPhrase = att.catchPhrase;
}
demo(subject){
return `Today we are learning about ${subject}.`
}
grade(student, subject){
return `${student} recieves a perfect score on ${subject}`
}

}

class Student extends Person{
constructor(att){
super(att)
this.previousBackground = att.previousBackground;
this.className = att.className;
this.favSubjects = att.favSubjects;
}
listSubjects(){
for (let i = 0 ; i<this.favSubjects.length; i++){
console.log(this.favSubjects[i])
}
}
PRAssignment(subject){
return `${this.name} has submited a PR for ${subject}`
}
sprintChallenge(subject){
return `${this.name} has begun the sprint challenge on ${subject}`
}
}

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

const alex = new Student({
name: 'Alex Stillo',
location: 'Houston',
age: 21,
previousBackground: 'Transcore',
className: 'Web21',
favSubjects: ['Programming', 'History', "LA", "Math"],
});

const will = new ProjectManagers({
name: 'Will U',
location: 'Abeline',
age: 26,
favLanguage: 'Javascript',
specialty: 'Front-end',
catchPhrase: 'Wubba lubba dub dub',
gradClassName: 'Havard',
favInstructor: 'Dan Levy'
})
const dan = new Instructor({
name: 'Dan Levy',
location: 'Denver',
age: 28,
favLanguage: 'React',
specialty: 'back-end',
catchPhrase: 'Wubba lubba wubba dub',
})
console.log('******************')
console.log(alex.speak())
console.log(alex.listSubjects())
console.log(alex.PRAssignment('Math'))
console.log(alex.sprintChallenge('Javascript 4'))
console.log(alex.previousBackground)
console.log("*******************")
console.log(will.speak())
console.log(will.catchPhrase)
console.log(will.standup('web21_will'))
console.log(will.debugsCode('alex stillo', 'javascript 4'))
console.log(will.gradClassName)
console.log("*******************")
console.log(dan.speak())
console.log(dan.demo('Javascript 3'))
console.log(dan.grade('alex stillo', 'javascript 3'))
console.log(dan.catchPhrase)




93 changes: 88 additions & 5 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,92 @@
/*
class GameObject{
constructor(att){
this.createdAt = att.createdAt;
this.name = att.name;
this.dimensions = att.dimensions;
}
destroy(){
return `${this.name} was removed from the game`;
}
}
class CharacterStats extends GameObject{
constructor(att){
super(att)
this.healthPoints = att.healthPoints;
}
takeDamage(){
return `${this.name} took damage`
}
}
class Humanoid extends CharacterStats{
constructor(att){
super(att)
this.team = att.team;
this.weapons = att.weapons;
this.language = att.language;
}
greet(){
return `${this.name} offers a greeting in ${this.language}`
}
}

Prototype Refactor

1. Copy and paste your code or the solution from yesterday
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',
});

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.
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.