Repository navigation
Expand file tree
/
Copy pathlambda-classes.js
More file actions
259 lines (203 loc) · 6.56 KB
/
Copy pathlambda-classes.js
File metadata and controls
259 lines (203 loc) · 6.56 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// CODE here for your Lambda Classes
// Person is parent
class Person{
constructor(attr){
this.name = attr.name;
this.age = attr.age;
this.location = attr.location;
}
intro(){
return `Hello my name is ${this.name}, I am from ${this.location}.`;
}
}
// Instructor is child of Person
class Instructor extends Person{
constructor(instructorAttr){
super(instructorAttr);
this.name = instructorAttr.name;
this.age = instructorAttr.age;
this.location = instructorAttr.location;
this.specialty = instructorAttr.specialty;
this.favLanguage = instructorAttr.favLanguage;
this.catchphrase = instructorAttr.catchphrase;
}
demo(subject){
return `Today we are learning about ${subject}`;
}
grade(student, subject){
return `${student.name} receives a perfect score on ${subject}`;
}
fickleGrading(student, max){
return (Math.floor(Math.random() * Math.floor(max))) + student.grade;
}
}
// Student is child of Person
class Student extends Person{
constructor(studentAttr){
super(studentAttr);
this.name = studentAttr.name;
this.age = studentAttr.age;
this.location = studentAttr.location;
this.previousBackground = studentAttr.previousBackground;
this.className = studentAttr.className;
this.favSubjects = studentAttr.favSubjects;
this.grade = studentAttr.grade;
}
listsSubjects(){
return `${this.favSubjects}`;
}
PRAssignment(subject){
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject){
return `${this.name} has begun sprint challenge on ${subject}`;
}
checkIfGraduate(){
if(this.grade > 70){
return `You can graduate!`;
} else {
return `Sorry, you're not ready to graduate yet.`;
}
}
}
// Project Manager is child of Instructor
class ProjectManagers extends Instructor{
constructor(projectManagersAttr){
super(projectManagersAttr);
this.name = projectManagersAttr.name;
this.age = projectManagersAttr.age;
this.location = projectManagersAttr.location;
this.specialty = projectManagersAttr.specialty;
this.favLanguage = projectManagersAttr.favLanguage;
this.catchphrase = projectManagersAttr.catchphrase;
this.gradClassName = projectManagersAttr.gradClassName;
this.favInstructor = projectManagersAttr.favInstructor;
}
standUp(channel){
return `${this.name} announces to ${channel}, @channel standy times!`;
}
debugsCode(student, subject){
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
// New Objects - Person
const personOne = new Person({
name: 'Sauron',
age: 8000,
location: 'Mordor'
})
const personTwo = new Person({
name: 'Melkor',
age: 8500,
location: 'Middle Earth'
})
// New Objects - Instructor
const instructorOne = new Instructor({
name: 'Gandalf',
age: 7000,
location: 'Middle Earth',
specialty: 'banishing Balrogs',
favLanguage: 'Elvish',
catchPhrase: 'You shall not pass!'
})
const instructorTwo = new Instructor({
name: 'Elrond',
age: 5000,
location: 'Rivendell',
specialty: 'Holding councils',
favLanguage: 'Old Elvish',
catchPhrase: 'Strangers from distant lands, friends of old, you have been summoned here to answer the threat of Mordor.',
})
const instructorThree = new Instructor({
name: 'Saruman',
age: 6500,
location: 'Orthanc',
specialty: 'making Orcs',
favLanguage: 'Orcish',
catchPhrase: 'Against the power of Mordor there can be no victory'
})
// New Objects - Student
const studentOne = new Student({
name: 'Frodo',
age: 30,
location: 'The Shire',
previousBackground: 'Shire aristocracy',
className: 'The Hobbits',
favSubjects: ['rings', 'brandywine', 'elvishArmor', 'Sting'],
grade: 92
})
const studentTwo = new Student({
name: 'Samwise',
age: 28,
location: 'The Shire',
previousBackground: 'gardening',
className: 'The Gaffers',
favSubjects: ['cooking', 'gardening', 'potatoes', 'poetry', 'Elves'],
grade: 100
})
const studentThree = new Student({
name: 'Merry',
age: 25,
location: 'The Shire',
previousBackground: 'Master of Buckland',
className: 'The Ent Homies',
favSubjects: ['breakfast', 'secondBreakfast', 'elevensies', 'ents'],
grade: 68
})
// New Objects - ProjectManagers
const pMOne = new ProjectManagers({
name: 'Aragorn',
age: 75,
location: 'Gondor',
specialty: 'not dying',
favLanguage: 'common tongue',
catchPhrase: 'You cannot wield it. None of us can. The One Ring answers to Sauron alone. It has no other master.'
})
const pMTwo = new ProjectManagers({
name: 'Legolas',
age: 212,
location: 'Woodland Realm',
specialty: 'wielding Elvish longbow',
favLanguage: 'Elvish',
catchPhrase: 'There is a fell voice on the air.'
})
const pMThree = new ProjectManagers({
name: 'Gimli',
age: 102,
location: 'Helms Deep',
specialty: 'wielding battle axes',
favLanguage: 'Dwarvish',
catchPhrase: 'Nobody tosses a dwarf!'
})
// intro method tests
console.log(personOne.intro());
console.log(instructorOne.intro());
console.log(studentOne.intro());
console.log(pMOne.intro());
// demo method tests
console.log(instructorTwo.demo('Mordors power'));
console.log(pMThree.demo('battle axes'));
// grade method tests
console.log(instructorThree.grade(studentOne, `the finer points of Saurons power.`));
console.log(pMTwo.grade(studentThree, `archery`));
// listsSubjects method test
console.log(studentTwo.listsSubjects());
console.log(studentOne.listsSubjects());
// pRAssignments method test
console.log(studentThree.PRAssignment(`Ent riding`));
console.log(studentOne.PRAssignment(`vanishing`));
// sprintChallenge method test
console.log(studentTwo.sprintChallenge(`boiling potatoes`));
console.log(studentOne.sprintChallenge(`trekking to Mordor`));
// standUp method test
console.log(pMOne.standUp(`Fellowship Members`));
console.log(pMThree.standUp(`Helms Deep Defenders`));
// debugsCode method test
console.log(pMTwo.debugsCode(studentThree, `brandywine`));
console.log(pMThree.debugsCode(studentTwo, `dwarvish cuisine`));
// fickleGrading method test
console.log(pMTwo.fickleGrading(studentThree, 10));
console.log(instructorOne.fickleGrading(studentTwo, 20));
// checkIfGraduate method test
console.log(studentTwo.checkIfGraduate());
console.log(studentThree.checkIfGraduate());