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 (169 loc) · 4.54 KB
/
Copy pathlambda-classes.js
File metadata and controls
201 lines (169 loc) · 4.54 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
//Person Class Starts
class Person {
constructor(attributes) {
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
this.gender = attributes.gender;
}
//Method
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
//Person Class Ends
//Instructor Clas Starts
class Instructor extends Person {
constructor(instructorAttributes) {
super(instructorAttributes);
this.speciality = instructorAttributes.speciality;
this.favLanguage = instructorAttributes.favLanguage;
this.catchPhrase = instructorAttributes.catchPhrase;
}
//Methods
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`;
}
calculate(student) {
return Math.floor(${student.grade} + Math.random());
}
}
//Instructor Class Ends
//Student Class Starts
class Student extends Person {
constructor(studentAttributes){
super(studentAttributes);
this.previousBackground = studentAttributes.previousBackground;
this.className = studentAttributes.className;
this.favSubjects = studentAttributes.favSubjects;
this.grade = studentAttributes.grade;
}
//Methods
listSubjects() {
return this.favSubjects.join(", ");
}
PRAssignments(student, subject) {
return `${student.name} has submitted a PR for ${subject}`;
}
sprintChallenge(student, subject) {
return `${student.name} has begun spring challenge on ${subject}`;
}
}
//Student Class Ends
//Project Manager Starts
class ProjectManagers extends Instructor {
constructor(pmAttributes) {
super(pmAttributes);
this.gradClassName = pmAttributes.gradClassName;
this.favInstructor = pmAttributes.favInstructor;
}
//Methods
standUP(slackChannel) {
return `${this.name} announces to ${slackChannel}, @channel standy times!`;
}
debugsCode(student ,subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
//Project Manager Ends
//Object for Person
const fred = new Person({
name: 'Fred',
location: 'Bedrock',
age: 35,
gender: 'male',
grade: 80
});
const wilma = new Person({
name: 'Wilma',
location: 'Bedrock',
age: 37,
gender: 'female',
grade: 50
});
//Object for Person
//Object for Instructor
const tim = new Instructor({
name: 'tim',
location: 'Seattle',
age: 37,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`,
grade: 85
});
const bob = new Instructor({
name: 'Bob',
location: 'NY',
age: 40,
gender: 'male',
favLanguage: 'C++',
specialty: 'Back-end',
catchPhrase: `Noice!`,
grade: 90
});
//Object for Instructor
//Object for Student
const susie = new Student({
name: 'Susie',
location: 'Florida',
age: 27,
gender: 'female',
previousBackground: 'Hair-stylist',
className: 'CS100',
favSubjects: ['Math', 'Java', 'Hair Cutting'],
grade: 70
});
const jim = new Student({
name: 'Jim',
location: 'Texas',
age: 25,
gender: 'male',
previousBackground: 'FireFighter',
className: 'CS90',
favSubjects: ['English', 'HTML', 'Video Games'],
grade: 94
});
//Object for Student
//Object for PM
const kevin = new ProjectManagers({
name: 'Kevin',
location: 'California',
age: 20,
gender: 'male',
gradClassName: 'CS25',
favInstructor: 'Josh',
grade: 73
});
const lilly = new ProjectManagers({
name: 'Lilly',
location: 'North Carolina',
age: 22,
gender: 'female',
gradClassName: 'CS26',
favInstructor: 'Eric',
grade: 82
});
//Object for PM
console.log(fred.name);
console.log(fred.location);
console.log(fred.age);
console.log(fred.gender);
console.log(wilma.name);
console.log(wilma.location);
console.log(wilma.age);
console.log(wilma.gender);
console.log(lilly.grade(jim, 'math'));
console.log(kevin.standUP('CS100'));
console.log(kevin.debugsCode(jim, 'math'));
console.log(bob.grade(kevin, 'english'));
console.log(tim.demo('books'));
console.log(bob.speak());
console.log(susie.PRAssignments(jim, 'math'));
console.log(jim.listSubjects());
console.log(jim.sprintChallenge(fred, "reading"));
console.log(calculate(jim));