forked from bloominstituteoftechnology/JavaScript-IV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda-classes.js
More file actions
122 lines (110 loc) · 3.38 KB
/
Copy pathlambda-classes.js
File metadata and controls
122 lines (110 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// CODE here for your Lambda Classes
class Person {
constructor(attributes) {
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
this.gender = attributes.gender;
}
introduce() {
return `Hello, my name is ${this.name}, I am from ${this.location}.`
}
}
class Instructor extends Person{
constructor(instructorAttrs) {
super(instructorAttrs);
this.specialty = instructorAttrs.specialty;
this.favLanguage = instructorAttrs.favLanguage;
this.catchPhrase = instructorAttrs.catchPhrase;
}
demo(subject) {
return `today we are learning about ${subject}.`
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject} `
}
}
const Gene = new Instructor({
name: 'Gene Cousineau',
age: 65,
location: 'L.A.',
gender: 'M',
specialty: 'Teaching acting',
favLanguage: 'the language of Theatre',
catchPhrase: 'You\'re never going to see the inside of this acting class again!'
});
const Fuches = new Instructor({
name: 'Fuches',
age: 58,
location: 'L.A.',
gender: 'M',
specialty: 'handling the "business"',
favLanguage: 'money',
catchPhrase: 'BARRY, YOU\'RE ALIVE!',
})
class Student extends Person {
constructor(studentAttrs) {
super(studentAttrs);
this.previousBackground = studentAttrs.previousBackground;
this.className = studentAttrs.className;
this.favSubjects = studentAttrs.favSubjects;
}
listsSubjects(arr) {
return `${this.favSubjects}; `
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun a sprint challenge on ${subject}`;
}
}
const Barry = new Student({
name: 'Barry Berkman',
age: 35,
location: 'L.A.',
gender: 'M',
previousBackground: 'Hitman',
className: 'Cousineau\'s Acting Class',
favSubjects: ['Acting', 'Shooting guns', 'daydreaming about Sally'],
});
const Sally = new Student({
name: 'Sally Reed',
age: 29,
location: 'L.A.',
gender: 'F',
previousBackground: 'Acting',
className: 'Cousineau\'s Acting Class',
favSubjects: ['Acting', 'Auditioning'],
})
class ProjectManager extends Instructor {
constructor(PMAttrs) {
super(PMAttrs);
this.gradClassName = PMAttrs.gradClassName;
this.favInstructor = PMAttrs.favInstructor;
}
standUp(slackChannel) {
return `${this.name} announces to ${slackChannel}, @channel standy time!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
const Hank = new ProjectManager ({
name: 'Noho Hank',
age: 32,
location: 'L.A.',
gender: 'M',
specialty: 'being a Mobster',
favLanguage: 'Chechen',
catchPhrase: 'We will find you, and we will kill you.',
gradClassName: 'right-hand man',
favInstructor: 'Goran Pazar',
})
console.log(Gene.demo('MacBeth'));
console.log(Fuches.grade(Barry, 'Killing the target'));
console.log(Barry.listsSubjects(this.favSubjects));
console.log(Sally.PRAssignment('playing MacBeth'));
console.log(Barry.sprintChallenge('stopping Chris from saying anything'));
console.log(Hank.standUp('the mobsters'));
console.log(Hank.debugsCode(Barry, 'CSS'));