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


// base class of Person
// props: name, age, location, gender
// method: speak

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

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


// Instructor class
// props: specialty, favLanguage, catchPhrase // props from parent: name, age, location, gender
// method: demo, grade

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

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

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

//Student Class
//props: previousBackground, className, favSubjects // props from parent: name, age, location, gender
//methods: listsSubjects, PRAssignment, sprintChallenge

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

// takes array of strings and spits out first string for each iteration of loop until all subjects have been listed.
listsSubjects() {
for (let i=0; i=this.favSubjects.length; i++) {
console.log(this.favSubjects.shift());
}
}

PRAssignment (subject) {
return console.log(`${this.name} has submitted a PR for ${subject}`);
}

sprintChallenge (subject) {
return console.log(`${this.name} has begun the sprint challenge on ${subject}`);
}
}

// Project Manager class
// props: gradClassName, favInstructor // props from parents: specialty, favLanguage, catchPhrase, name, age, location, gender
// methods: standUp, debugsCode

class ProjectManager extends Instructor {
constructor(PMinfo) {
super(PMinfo);
this.gradClassName = PMinfo.gradClassName;
this.favInstructor = PMinfo.favInstructor;
}

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

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

// Test objects for classes

// Persons
const ppam = new Person({
name: 'Pam',
location: 'Somewhere over the Rainbow',
age: 120,
gender: 'female'
});

// Test logs

console.log(ppam.name);
console.log(ppam.age);
ppam.speak();

//Instructors
const igeorge = new Instructor({
name: 'George',
location: 'Paris',
age: 31,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `I like to move it.`
});


const ibeth = new Instructor({
name: 'Beth',
location: 'Detroit',
age: 37,
gender: 'female',
favLanguage: 'CSS',
specialty: 'Front-end',
catchPhrase: `I like to design it.`
});

//test logs continued

console.log(igeorge.favLanguage);
console.log(ibeth.age);
console.log(igeorge.specialty);
igeorge.demo('Javascript');

// Students
const sphil = new Student({
name: 'Phil',
location: 'London',
age: 25,
gender: 'male',
previousBackground: 'Barrista',
className: 'Web19',
favSubjects: ['JavaScript', 'Video Editing', 'Greek Philosophy', 'Cooking']
});

const scourtney = new Student({
name: 'Courtney',
location: 'Los Angeles',
age: 22,
gender: 'female',
previousBackground: 'Student',
className: 'Web19',
favSubjects: ['Shakespeare', 'Chemistry']
});

// Test logs continued
ibeth.grade(sphil, 'Javascript IV');
console.log(sphil.name);
sphil.listsSubjects();
scourtney.listsSubjects();


// Project Managers

const pmanya = new ProjectManager({
name: 'Anya',
location: 'Austin',
age: 30,
gender: 'female',
favLanguage: 'HTML',
specialty: 'All of it',
catchPhrase: `I like to prove it.`,
gradClassName: `Web18`,
favInstructor: `George`
});

//test logs continued

console.log(pmanya.gradClassName);
console.log(pmanya.favInstructor);
pmanya.standUp(`web19_anya`);
pmanya.debugsCode(scourtney, `Javascript IV`);
Loading