Repository navigation
Expand file tree
/
Copy pathlambda-classes.js
More file actions
254 lines (224 loc) · 7.29 KB
/
Copy pathlambda-classes.js
File metadata and controls
254 lines (224 loc) · 7.29 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
// borrowed from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
class Person {
constructor(attributes) {
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
class Instructor extends Person {
constructor(instructorAttributes) {
super(instructorAttributes);
this.specialty = instructorAttributes.specialty;
this.favLanguage = instructorAttributes.favLanguage;
this.catchPhrase = instructorAttributes.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`;
}
giveActualGrade(student) {
return `${student.name} is getting a ${student.grade} at Lambda School`;
}
mark(student) {
let randomMark = getRandomInt(-10, 11);
student.grade+= randomMark;
return `${student.name} was marked ${randomMark} points. ${student.name}'s grade is now ${student.grade}`
}
}
class Student extends Person {
constructor(studentAttributes) {
super(studentAttributes);
this.previousBackground = studentAttributes.previousBackground;
this.className = studentAttributes.className;
this.favSubjects = studentAttributes.favSubjects;
this.grade = studentAttributes.grade;
}
listsSubjects() {
let endString = '';
for (let i = 0; i < this.favSubjects.length; i++) {
endString += this.favSubjects[i] + ' ';
}
return endString;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`;
}
graduate() {
if (this.grade >= 70) {
return `${this.name} has graduated!`
} else return `${this.name}'s grade is too low. They need to do more work before they can graduate`
}
}
class ProjectManager extends Instructor {
constructor(projectManagerAttributes) {
super(projectManagerAttributes);
this.gradClassName = projectManagerAttributes.gradClassName;
this.favInstructor = projectManagerAttributes.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}`;
}
}
const dan = new Instructor({
name: 'Dan',
age: 'Infinity',
location: 'Denver',
specialty: 'Relentless Debugger',
favLanguage: 'JavaScript, Python, Elm, ReasonML, SmallTalk, Haskell, C#, Java, Rust, Go, Ruby, Crystal, Elixir, Lua, and Julia',
catchPhrase: 'If you can do the thing, you can get paid to do the thing!',
});
const matthew = new Instructor({
name: 'Matthew',
age: 29,
location: 'Toronto',
specialty: 'eating donuts',
favLanguage: 'French',
catchPhrase: 'ne pas subir',
});
const isaiah = new Student({
name: 'Isaiah',
age: 18,
location: 'Florida',
previousBackground: 'High School last month',
className: 'Web21',
grade: 100,
favSubjects: ['Html', 'CSS', 'JavaScript'],
});
const kevin = new Student({
name: "Kevin",
age: 28,
location: "California",
previousBackground: "Table Games Dealer",
className: "WEB21",
grade: 95,
favSubjects: ['Html', 'CSS', 'JavaScript'],
});
const nisa = new Student({
name: 'Nisa',
age: 25,
location: 'Ohio',
previousBackground: 'Debt Collector',
className: 'Web21',
grade: 100,
favSubjects: ['Html', 'CSS', 'JavaScript'],
});
const joscelyn = new Student({
name: "Joscelyn",
age: 29,
location: "California",
previousBackground: "English teacher",
className: 'Web21',
grade: 91,
favSubjects: ["Computer Science", "Philosophy", "English"],
});
const marguel = new ProjectManager({
name: 'Marguel',
age: 'Maybe 26',
gradClassName: 'WEBPT2',
favInstructor: 'Me?',
location: 'California',
specialty: 'React',
favLanguage: 'JavaScript, Python, Elm etc.',
catchPhrase: "Practice Flex Zombies !!!",
});
const brandon = new ProjectManager({
name: 'Brandon',
age: '34',
gradClassName: 'WEB18',
favInstructor: 'Professor Lambda',
location: 'Maine',
specialty: 'Redux',
favLanguage: 'JavaScript, C++, Python.',
catchPhrase: "You shall not pass!",
});
const mary = new ProjectManager({
name: 'Mary',
age: '24',
gradClassName: 'WEB18',
favInstructor: 'Josh Knell',
location: 'New York',
specialty: 'Express and Node.js',
favLanguage: 'Javascript',
catchPhrase: "That looks AWESOME",
});
const christian = new ProjectManager({
name: 'Christian',
age: '32',
gradClassName: 'WEB18',
favInstructor: 'Every Instructor in Lambda',
location: 'Seattle, WA',
specialty: 'Data Structures & Algorithms',
favLanguage: 'JavaScript',
catchPhrase: "Dont forget your daily commit.",
});
const pat = new ProjectManager({
name: 'Pat',
age: '38',
gradClassName: 'WEB18',
favInstructor: 'Brett Madrid',
location: 'Petaluma, Ca',
specialty: 'Empathetic to the struggle of Redux',
favLanguage: 'JavaScript',
catchPhrase: 'Lets google that together.'
});
const darren = new ProjectManager({
name: 'Darren',
age: '25',
gradClassName: 'WEB18',
favInstructor: 'Josh Knell',
location: 'North Carolina',
specialty: 'React',
favLanguage: 'Javascript',
catchPhrase: 'Gang. Gang.',
});
const austin = new ProjectManager({
name: 'Austin',
age: '23',
gradClassName: 'WEB18',
favInstructor: 'Josh Knell',
location: 'Somewhere',
specialty: 'Java',
favLanguage: 'Java',
catchPhrase: ":eggplant:",
});
console.log(austin.name);// Austin
console.log(matthew.location);// Toronto
console.log(kevin.age);// 28
console.log(dan.speak());// Hello my name is Dan, I am from Denver
console.log(joscelyn.listsSubjects())// Computer Science,Philosophy,English
console.log(isaiah.sprintChallenge('prototypical inheritance'));// Isaiah has begun sprint challenge on prototypical inheritance
console.log(pat.catchPhrase);//Lets google that together
console.log(mary.debugsCode(joscelyn, 'CSS'));// Mary debugs Joscelyn's code on CSS
console.log(dan.grade(joscelyn, 'JavaScript'));// Joscelyn receives a perfect score on JavaScript
console.log(dan.giveActualGrade(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(dan.mark(joscelyn));
console.log(joscelyn.graduate());