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
218 changes: 218 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,219 @@
// CODE here for your Lambda Classes



//Person
/* First we need a Person class. This will be our `base-class` Person receives `name` `age` `location` `gender` all as props Person receives `speak` as a method. This method logs out a phrase `Hello my name is Fred, I am from Bedrock` where `name` and `location` are the object's own props */

class Person{
constructor(bio){
this.name = bio.name;
this.age = bio.age;
this.location = bio.location;
this.gender = bio.gender
}

speak(){
console.log(`Hello my name is ${this.name}, I am from ${this.location}.`)
}
}

//Instructor
/* Now that we have a Person as our base class, we'll build our Instructor class.
Instructor uses the same attributes that have been set up by Person
Instructor has the following unique props:
`specialty` what the Instructor is good at i.e. 'redux'
`favLanguage` i.e. 'JavaScript, Python, Elm etc.'
`catchPhrase` i.e. `Don't forget the homies`
Instructor has the following methods:
`demo` receives a `subject` string as an argument and logs out the phrase 'Today we are learning about {subject}' where subject is the param passed in.
`grade` receives a `student` object and a `subject` string as arguments and logs out '{student.name} receives a perfect score on {subject}' */

class Instructor extends Person {
constructor (instructorinfo){
super (instructorinfo);
this.specialty = instructorinfo.specialty;
this.favLanguage = instructorinfo.favLanguage;
this.catchPhrase = instructorinfo.catchPhrase;
}

demo(subject) {
console.log(`Today we are learning about ${subject}`);
}

grade(student, subject) {
console.log(`${student.name} receives a perfect score on ${subject}`)
}

}

//Student
/* Now we need some students!
Student uses the same attributes that have been set up by Person
Student has the following unique props:
`previousBackground` i.e. what the Student used to do before Lambda School
`className` i.e. CS132
`favSubjects`. i.e. an array of the student's favorite subjects ['Html', 'CSS', 'JavaScript']
Student has the following methods:
`listsSubjects` a method that logs out all of the student's favoriteSubjects one by one.
`PRAssignment` a method that receives a subject as an argument and logs out that the `student.name has submitted a PR for {subject}`
`sprintChallenge` similar to PRAssignment but logs out `student.name has begun sprint challenge on {subject}`
*/

class Student extends Person {
constructor (studentinfo){
super(studentinfo);
this.previousBackground = studentinfo.previousBackground;
this.className = studentinfo.className;
this.favSubjects = studentinfo.favSubjects;
}

listsSubjects() {
console.log(...this.favSubjects);
}

PRAssignment(student, subject){
console.log(`${student.name} has submitted a PR for ${subject}`)
}

sprintChallenge(student, subject){
console.log(`${student.name} has begun sprint challenge on ${subject}`)
}
}


//Project Mananger
/* Now that we have instructors and students, we'd be nowhere without our PM's
ProjectManagers are extensions of Instructors
ProjectManagers have the following uniqe props:
`gradClassName`: i.e. CS1
`favInstructor`: i.e. Sean
ProjectManangers have the following Methods:
`standUp` a method that takes in a slack channel and logs `{name} announces to {channel}, @channel standy times!​​​​​
`debugsCode` a method that takes in a student object and a subject and logs out `{name} debugs {student.name}'s code on {subject}` */

class ProjectManagers extends Instructor {
constructor (pm){
super (pm);
this.gradClassName = pm.gradClassName;
this.favInstructor = pm.favInstructor;
}

standUp(pm, channel) {
console.log(`${pm.name} announces to ${channel}, @channel standy times!`)
}

debugsCode(pm, student, subject) {
console.log(`${pm.name} debugs ${student.name}'s code on ${subject}`)
}
}

//Instructors

const Freya = new Instructor ({
name: 'Freya',
age: 30,
location: 'Athens',
gender: 'Female',
specialty: "JavaScript",
favLanguage: "Css",
catchPhrase: "Gotta code them all!"
});

const Odin = new Instructor ({
name: 'Odin',
age: 49,
location:'Norway',
gender: 'Male',
specialty: "Python",
favLanguage: "Python",
catchPhrase: "And the thunder rolls"
});

const Nyxx = new Instructor ({
name: 'Nyxx',
age: 29,
location: 'Paris',
gender: 'Female',
specialty: "HTML&CSS",
favLanguage: "PhP",
catchPhrase: "Startastic Job guys!"
});

//PMs

const Athena = new ProjectManagers ({
name: 'Athena',
age: 20,
location: 'Denver',
gender: 'Female',
gradClassName: "CS15",
favInstructor: "Odin"
});

const Leta = new ProjectManagers ({
name: 'Leta',
age: 25,
location: 'Alanta',
gender: 'Female',
gradClassName: "CS14",
favInstructor: "Nyxx"
});

const Zypher = new ProjectManagers ({
name = 'Zypher',
age = 30,
location = 'New York City',
gender = 'Male',
gradClassName: "CS14",
favInstructor: "Nyxx"
})

//Students

const asteria = new Student ({
name: 'Asteria',
age: 20,
location: 'Denver',
gender: 'Female',
previousBackground: "Some html and css knowledge",
favSubjects: ["JavaScript", "html"]
})

const ani = new Person ({
name: 'Ani',
age: 21,
location: 'Orlando',
gender: 'Female',
previousBackground: "Web Design",
favSubjects: ["CSS", "html", "React"]
})

const rogue = new Person ({
name: 'Rogue',
age: 32,
location: 'Phoenix',
gender: 'Male',
previousBackground: "Backend",
favSubjects: ["MySql", "PHP", "Ruby"]
})

const ren = new Person ({
name: 'Ren',
age: 26,
location: 'Olympia',
gender: 'Male',
previousBackground: "Some JavaScript",
favSubjects: ["JavaScript"]
})

//Invoke

Nyxx.speak();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work with these! I love the names you chose 💯

Odin.demo('JavaScript');
Freya.grade(asteria, 'JavaScript');
asteria.listsSubjects();
asteria.PRAssignment(asteria, "Advance Css");
asteria.sprintChallenge(asteria, "Applied JS");
Athena.debugsCode(Athena, asteria, "Js IV");
Athena.standUp(Athena, 'general')
101 changes: 101 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,104 @@ 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 (attributes) {
this.createdAt = attributes.createdAt;
this.dimensions = attributes.dimensions;
}

destroy() {
return `${this.name} was removed from the game.`;
}
}

class CharacterStats extends GameObject{
constructor (stats){
super(stats);
this.healthPoints = stats.healthPoints;
this.name = stats.name;
}

takeDamage() {
return `${this.name} took damage.`;
}

}

class Humanoid extends CharacterStats {
constructor (about){
super(about);
this.team = about.team;
this.weapons = about.weapons;
this.language = about.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()); // Sir Mustachio was removed from the game.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all look perfect! Isn't the class syntax so clean? 🌊