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
241 lines (210 loc) · 6.31 KB
/
Copy pathlambda-classes.js
File metadata and controls
241 lines (210 loc) · 6.31 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
// // 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;
// }
// speak() {
// return `Hello my name is ${this.name}, I am from ${this.location}`;
// }
// }
// class Instructor extends Person {
// constructor(attributes) {
// super(attributes);
// this.specialty = attributes.specialty;
// this.favLanguage = attributes.favLanguage;
// this.catchPhrase = attributes.catchPhrase;
// }
// demo(subject) {
// return `Today we are learning about ${subject}`;
// }
// grade(student, subject) {
// return `${student.name} receives a perfect score on ${subject}`
// }
// }
// class Student extends Person {
// constructor(attributes) {
// super(attributes);
// this.previousBackground = attributes.previousBackground;
// this.className = attributes.className;
// this.favSubjects = attributes.favSubjects; // array [JS, HTML, life]
// }
// listsSubjects() {
// // let emptyArray = [];
// this.favSubjects.forEach(function(element) {
// console.log(element);
// // emptyArray.push(element);
// });
// }
// PRAssignment(subject) {
// return `${this.name} has submitted a PR for ${subject}`;
// }
// sprintChallenge(subject) {
// return `${this.name} has begun sprint challenge on ${subject}`;
// }
// }
// class ProjectManager extends Instructor {
// constructor(attributes) {
// super(attributes);
// this.gradClassName = attributes.gradClassName;
// this.favInstructor = attributes.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}`
// }
// }
// /* ------ Exploratory Laboratory ------ */
// const davidAttr = {
// "name": "David",
// "age": 36,
// "location": "Seattle",
// "gender": "Male",
// "previousBackground": "Engineering",
// "className": "CS10",
// "favSubjects": ["JavaScript", "HTML", "CSS", "Computer Science"],
// }
// const david = new Student(davidAttr);
// console.log(david);
// console.log(david.location);
// console.log(david.className);
// david.listsSubjects(); // logs to console like we expect
// console.log(david.PRAssignment('JavaScript'));
// const csabaAttr = {
// "name": "Csaba",
// "age": 34,
// "location": "Fontana",
// "gender": "male",
// "specialty": "Being awesome",
// "favLanguage": "JavaScript",
// "catchPhrase": "\"Any blockers?\"",
// "gradClassName": "CS5",
// "favInstructor": "Josh Knell",
// }
// const csaba = new ProjectManager(csabaAttr);
// console.log(csaba);
// console.log(csaba.age);
// console.log(csaba.specialty);
// console.log(csaba.grade(david, 'JavaScript'));
// console.log(csaba.gradClassName);
// console.log(csaba.standUp("CS10_Csaba"));
class Person{
constructor(attr){
this.name = attr.name;
this.age = attr.age;
this.location = attr.location;
this.gender = attr.gender;
}
speak(){
return ` Hello my name is ${this.name}m I am from ${location}`
}
}
class Instructor extends Person{
constructor(attr){
super(attr)
this.speciality = attr.speciality;
this.favLanguage = attr.favLanguage;
this.catchPhrase = attr.catchPhrase;
}
addGrade(student) {
if(Math.random() < 0.7){
student.grade += Math.floor(Math.random() * 10)
}else{
student.grade -= Math.floor(Math.random() * 10)
}
return "Student has been graded"
}
demo(subject){
return `Today we are learning about ${subject}`
}
grade(){
return `${student.name} recieves a perfect score on ${variables}`
}
}
/////
let studentScore = 0;
function studentScoreGen() {
return studentScore = Math.floor(Math.random() * 61)
}
console.log(studentScoreGen())
/////
class Student extends Person{
constructor(attr){
super(attr)
this.grade = studentScoreGen();
this.previousBackground = attr.previousBackground
this.className = attr.className;
this.favSubjects = attr.favSubjects;
}
listsSubjects() {
this.favSubjects.forEach(function(element){
console.log(element)
})
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`
}
sprintChallenge(subject){
return `${student.name} has begun sprint challenge on {subject}`
}
graduate() {
if( this.grade >= 70){
console.log("Yay we graduated")
return true
}else{
return false
}
}
}
class ProjectManager extends Instructor{
constructor(attr){
super(attr)
this.gradClassname = attr.gradClassname;
this.favInstructor = attr.favInstructor;
}
standUp(slackNum){
return `${this.name} announces to ${slackNum}, @channel standby times`
}
debugsCode(){
return `${this.name} debugs ${student.name}'s code on ${subject}`
}
}
const DavidAttr = {
"name": "David",
"grade": studentScore,
"age": 36,
"location": "Seattle",
"gender": "Male",
"previousBackground": "Engineering",
"className": "CS10",
"favSubjects": ["JavaScript", "HTML", "CSS", "Computer Science"],
}
const David = new Student(DavidAttr)
const csabaAttr = {
"name": "Csaba",
"age": 34,
"location": "Fontana",
"gender": "male",
"specialty": "Being awesome",
"favLanguage": "JavaScript",
"catchPhrase": "\"Any blockers?\"",
"gradClassName": "CS5",
"favInstructor": "Josh Knell",
}
const csaba = new ProjectManager(csabaAttr);
function grading(student, instructor){
while(student.grade <= 70){
instructor.addGrade(student);
console.log(student.grade)
}
console.log(student.graduate());
}
// console.log(David.className);
// console.log(csaba.catchPhrase);
// console.log(David.graduate())
// console.log(David.grade);
grading(David, csaba);