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
199 lines (172 loc) · 4.5 KB
/
Copy pathlambda-classes.js
File metadata and controls
199 lines (172 loc) · 4.5 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
// Stretch Addition
function gradePapers(obj1, obj2){
do{
obj1.grading(obj2);
console.log(obj2.grade);
}
while(obj2.grade < 70);
return obj2.graduate();
};
// Main Assignment
class Person {
constructor(obj){
this.name = obj.name;
this.age = obj.age;
this.location = obj.location;
}
speak(){
console.log(`Hello, my name is ${this.name}. I am from ${this.location}!`)
}
} // Person
class Instructor extends Person {
constructor(obj){
super(obj);
this.specialty = obj.specialty;
this.favLanguage = obj.favLanguage;
this.catchPhrase = obj.catchPhrase;
}
demo(subject){
console.log(`Today we are learning about ${subject}.`)
}
grade(student, subject){
console.log(`${student.name} receives a perfect score on ${subject}!`)
}
grading(obj){
if((Math.floor(Math.random() * 11)) < 7){
obj.grade -= 10;
return obj.grade;
} else {
obj.grade += 20;
return obj.grade;
}
}
} // Instructor instanceof Person
class Student extends Person{
constructor(obj){
super(obj);
this.previousBackground = obj.previousBackground;
this.className = obj.className;
this.favSubjects = obj.favSubjects;
this.grade = obj.grade;
}
listsSubjects(){
console.log(this.favSubjects);
}
prAssignments(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(`Congrats, ${this.name}, you have finished ${this.specialty}!`);
} else {
console.log(`We're sorry ${this.name}, but you have not passed ${this.specialty} until you have a 70%!`);
}
}
} // Student instanceof Person
class ProjectManager extends Instructor{
constructor(obj){
super(obj);
this.gradClassName = obj.gradClassName;
this.favInstructor = obj.favInstructor;
}
standup(channel){
console.log(`${this.name} announces to ${channel}, @channel standby times!`);
}
debugCode(obj, subject){
console.log(`${this.name} debugs ${obj.name}'s code on ${subject}`);
}
} // Project Manager instanceof Instructor
// TEST OBJECTS
const int1 = new Instructor({
name: "george",
age: 22,
gender: '?',
favLanguage: 'JavaScript',
specialty: 'cloud',
catchPhrase: 'Jumping Beans!'
});
const int2 = new Instructor({
name: "jim",
age: 44,
gender: 'F',
favLanguage: 'Swift',
specialty: 'things',
catchPhrase: 'Looking Beans!'
});
const int3 = new Instructor({
name: "tom",
age: 71,
gender: 'M',
favLanguage: 'Python',
specialty: 'stuff',
catchPhrase: 'Special Beans!'
});
const stu1 = new Student({
name: "exacto",
age: 4,
grade: (Math.floor(Math.random() * 10) * Math.floor(Math.random() * 10)),
location: 'Craft room',
gender: '?',
favLanguage: 'babble',
specialty: 'not walking',
catchPhrase: 'Touch?'
}); // random generate grade!!!
const stu2 = new Student({
name: "sun",
age: 2,
grade: 0,
gender: 'F',
favLanguage: 'c++',
specialty: 'engineer',
catchPhrase: 'climbing Beans!'
});
const stu3 = new Student({
name: "moon",
age: 1,
grade: 69,
specialty: 'Ergonomics',
gender: '?',
favLanguage: 'Django',
specialty: 'software',
catchPhrase: 'computing Beans!'
});
const pm1 = new ProjectManager({
name: "artic",
age: 22,
gender: '?',
favLanguage: 'JavaScript',
specialty: 'teaching',
catchPhrase: 'learning Beans!'
});
const pm2 = new ProjectManager({
name: "oscar",
age: 32,
gender: '?',
favLanguage: 'objective c',
specialty: 'who knows',
catchPhrase: 'questioning Beans!'
});
const pm3 = new ProjectManager({
name: "link",
age: 72,
gender: 'M and only M',
favLanguage: 'Hyrule',
specialty: 'Water Temple',
catchPhrase: 'Do not hit those chickens!'
});
// TEST STATEMENTS
// stu1.speak();
// pm2.debugCode(stu3, 'Advanced CSS');
// int3.grade(stu1, 'Science');
// pm3.standup('web19_help');
// stu3.sprintChallenge('Javascript');
// console.log(stu2.grade);
// console.log(int2.grading(stu2));
// stu3.graduate();
// console.log(stu2.grade);
// int2.grading(stu3);
// console.log(stu2.grade);
gradePapers(int2, stu3);