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
181 changes: 181 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,182 @@
// 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}, and I am from ${this.location}`
}
}

const Kelsey = new Person({
name:'Kelsey',
age:23,
location:'Hawaii',
})

const John = new Person({
name:'John',
age:33,
location:'France',
})



console.log(Kelsey.speak())



class Instructor extends Person{
constructor(attrs){
super(attrs)
this.specialty = attrs.specialty;
this.favLanguage = attrs.favLanguage;
this.catchPhrase = attrs.catchPhrase;
this.subject = attrs.subject;
}
demo(){
return ` Today, we are learning about ${this.subject}`
}
grade(){
return `${this.name} receives a perfect score on ${this.subject}`
}
graded(grade){
return `${this.grade}` + (Math.floor(Math.random() * 100))
}
}



const Meghan = new Instructor({
name:'Meghan',
age:23,
location:'New-York',
specialty:'Redux',
favLanguage:'Italian',
catchPhrase:` Don't forget the homies`,
subject:'Algorithms'
})

const Ryan = new Instructor({
name:'Ryan',
age:33,
location:'France',
specialty:'Redux',
catchPhrase:' Don\'/t forget the homies',
subject:'History'
})


console.log(Meghan.demo())
console.log(Ryan.grade())


// favSubjects=['HTML', 'CSS', 'JavaScript']

class Student extends Instructor{
constructor(attr){
super(attr)
this.previousBackground = attr.previousBackground;
this.className = attr.className;
this.favSubjects = attr.favSubjects;

}
listsSubjects(){
return this.favSubjects.toString().split(',').join('\r\n');
}

PRAssingment(subject){
return `${this.name} has submitted a PR for ${this.subject}`

}
sprintChallenge(subject){
return `${this.name} has begun sprint challenge on ${this.subject}`
}
graduate(){
if(this.grade === 70){
return`${this.name} can graduate`
}else{
return`${this.name} has to study more`
}
}

// (this.grade>= 70) ? `${this.name} can graduate` : `${this.name} has to study more`

}




const Riley = new Student({
name:'Riley',
age:41,
subject:'Design',
location:'Mississippi',
className:'History101',
previousBackground:'Student',
favSubjects:['Computer Science','Math','JavaScript'],
grade:70,
})
const Mike = new Student({
name:'Mike',
subject:'Art',
className:'English',
previousBackground:'Student',
favSubjects:['History','Spanish','Public Speaking'],
grade:90,
})

console.log(Mike.graduate())
console.log(Riley.listsSubjects())
console.log(Riley.PRAssingment())
console.log(Mike.sprintChallenge())




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


const fred = new ProjectManage({
name: 'Fred',
location: 'Portland',
age: 37,
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`,
gradClassName:'CS1',
favInstructor:'Sean',
channel:'Lambda',
subject:'Math'
});
const Carrie = new ProjectManage({
name: 'Carrie',
location: 'Portland',
age: 34,
favLanguage: 'Python',
specialty: 'Back-end',
catchPhrase: `Don't forget the homies`,
gradClassName:'CS5',
favInstructor:'Sean',
channel:'Lambda',
subject:'Math'
});

console.log(fred.standUp())
console.log(Carrie.debugsCode())
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(at){
this.createdAt = at.createdAt;
this.name = at.name;
this.dimensions = at.dimensions;
}
destroy(){
return `${this.name} was removed from the game`;
}
}




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

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


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())