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
201 lines (176 loc) · 4.33 KB
/
Copy pathlambda-classes.js
File metadata and controls
201 lines (176 loc) · 4.33 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
console.log("🔥🔥🔥🔥🔥🔥🔥 PART II 🔥🔥🔥🔥🔥🔥🔥");
// CODE here for your Lambda Classes
// Person Class
class Person {
constructor(arg) {
this.name = arg.name;
this.age = arg.age;
this.location = arg.location;
this.gender = arg.gender;
}
speak() {
console.log(`Hello my name is ${this.name}, I am from ${this.location}.`);
}
}
// Instructor Class
class Instructor extends Person {
constructor(arg) {
super(arg);
this.speciality = arg.speciality;
this.favLanguage = arg.favLanguage;
this.catchPhrase = arg.catchPhrase;
}
demo(subject) {
console.log(`Today we are learning about ${subject}`);
}
grade(student, subject) {
let grade = Math.round(Math.random() * 10);
if (grade >= 5) {
student.grade = student.grade + grade;
} else {
student.grade = student.grade - grade;
}
console.log(
`${student.name} receives ${student.grade} score on ${subject}`
);
}
}
// Student Class
class Student extends Person {
constructor(arg) {
super(arg);
this.previousBackground = arg.previousBackground;
this.className = arg.className;
this.favSubjects = arg.favSubjects;
this.grade = arg.grade;
}
listSubjects() {
this.favSubjects.forEach(subject => {
console.log(`${subject}`);
});
}
PRAssignment(subject) {
console.log(`${this.name} has submitted a PR for ${subject}`);
}
sprintChallenge(subject) {
console.log(`${this.name} has begun sprint challenge on ${subject}`);
}
graduate() {
if (this.grade > 70) {
console.log(`${this.name} successfully graduated from Lambda School!`);
} else {
console.log("Extra work is needed. Keep pushing!");
}
}
}
// Project Manager Class
class ProjectManager extends Instructor {
constructor(arg) {
super(arg);
this.gradClassName = arg.gradClassName;
this.favInstructor = arg.favInstructor;
}
standUp(channel) {
console.log(`${this.name} announces to ${channel}, @channel standy times!`);
}
debugsCode(student, subject) {
console.log(`${this.name} debugs ${student.name}'s code on ${subject}`);
}
}
// Objects for Classes
// => Person objects
const brian = new Person({
name: "Brian",
age: 27,
location: "Athboy, Ireland",
gender: "M"
});
const tim = new Person({
name: "Tim",
age: 52,
location: "New York, USA",
gender: "M"
});
// => Instructor objects
const bernie = new Instructor({
name: "Bernie",
age: 49,
location: "Dublin, Ireland",
gender: "F",
speciality: "Functional programming",
favLanguage: "JavaScript",
catchPhrase: "If Hemingway Wrote JavaScript is a strange and beautiful book."
});
const thomas = new Instructor({
name: "Thomas",
age: 38,
location: "Köln, Germany",
gender: "M",
speciality: "React",
favLanguage: "JavaScript",
catchPhrase: "I React - you React!"
});
// => Student objects
const betty = new Student({
name: "Betty",
age: 19,
location: "Malmö, Norway",
gender: "F",
previousBackground: "School graduate",
className: "WEBEU3",
favSubjects: ["HTML", "CSS", "JS"],
grade: 80
});
const debie = new Student({
name: "Debie",
age: 24,
location: "Turin, Italy",
gender: "F",
previousBackground: "College dropout in UX",
className: "UXEU2",
favSubjects: ["Design Theory", "User Behaviour", "Testing"],
grade: 85
});
const robert = new Student({
name: "Robert",
age: 28,
location: "Dijon, France",
gender: "M",
previousBackground: "Digital marketing specialist",
className: "WEBEU3",
favSubjects: ["JS", "Computer Science", "Algorithms"],
grade: 50
});
const diana = new Student({
name: "Diana",
age: 31,
location: "Sofia, Bulgaria",
gender: "F",
previousBackground: "Graphic Designer",
className: "UXEU2",
favSubjects: ["Design Theory", "User Behaviour"],
grade: 90
});
// => ProjectManager objects
const martin = new ProjectManager({
name: "Martin",
age: 30,
location: "Warsaw, Poland",
gender: "M",
speciality: "React",
favLanguage: "JavaScript",
catchPhrase: "I React - you React!",
gradClassName: "CS5",
favInstructor: "Tim Apple"
});
const lucas = new ProjectManager({
name: "Lucas",
age: 32,
location: "Valencia, Spain",
gender: "M",
speciality: "React",
favLanguage: "JavaScript",
catchPhrase: "Siesta time!",
gradClassName: "CS3",
favInstructor: "Tim Apple"
});