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
170 lines (145 loc) · 3.92 KB
/
Copy pathlambda-classes.js
File metadata and controls
170 lines (145 loc) · 3.92 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
// CODE here for your Lambda Classes
// Base Class
class Person {
constructor(properties) {
this.name = properties.name;
this.age = properties.age;
this.location = properties.location;
this.gender = properties.gender;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
class Instructor extends Person {
constructor(instructorProps) {
super(instructorProps);
this.specialty = instructorProps.specialty;
this.favLanguage = instructorProps.favLanguage;
this.catchPhrase = instructorProps.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(subject, student) {
return `${student.name} receives a perfect score on ${subject}`;
}
score(student) {
const randomNum = Math.floor(Math.random() * 25);
// return student.grade += randomNum;
if (randomNum + student.grade > 100 && randomNum - student.grade >= 0) {
return (student.grade -= randomNum);
} else if (randomNum + student.grade <= 100) {
return (student.grade += randomNum);
} else {
return (student.grade += 1);
}
}
}
class Student extends Person {
constructor(studentProps) {
super(studentProps);
this.previousBackground = studentProps.previousBackground;
this.className = studentProps.className;
this.favSubjects = studentProps.favSubjects;
this.grade = studentProps.grade;
}
listSubjects() {
return `These are my favoirte subjects: ${this.favSubjects}`;
}
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} is ready to graduate!`;
} else {
return `${this.name} needs some more work!`;
}
}
}
class ProjectManager extends Instructor {
constructor(pmProps) {
super(pmProps);
this.gradClassName = pmProps.gradClassName;
this.favInstructor = pmProps.favInstructor;
}
standUp(channel) {
return `${
this.name
} announces to ${channel}, @${channel} standy times!`;
}
debugCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
// PEOPLE
const michael = new Instructor({
name: 'Michael',
location: 'Scranton',
age: 45,
gender: 'male',
favLanguage: 'Improv Comedy',
specialty: 'Front-end',
catchPhrase: `I love inside jokes. I'd love to be part of one one day.`
});
const josh = new Instructor({
name: 'Josh',
location: 'Provo',
age: 38,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Good morning FSW-14`
});
const ryan = new Student({
name: 'Ryan',
location: 'Youngstown',
age: 29,
gender: 'male',
previousBackground: 'Music',
className: 'FSW-14',
favSubjects: ['LESS', 'JavaScript', 'React', 'Express', 'Responsive Design'],
grade: 80
});
const pam = new Student({
name: 'Pam',
location: 'New York',
age: 30,
gender: 'female',
previousBackground: 'Receptionist',
className: 'FSW-12',
favSubjects: ['CSS', 'LESS', 'Art', 'Design', 'Responsive Design'],
grade: 90
});
const jim = new ProjectManager({
name: 'Jim',
location: 'Scranton',
age: 35,
gender: 'male',
previousBackground: 'Sales',
gradClassName: 'FSW-1',
favInstructor: josh
});
const dwight = new ProjectManager({
name: 'Dwight',
location: 'Schrute Farms',
age: 40,
gender: 'male',
previousBackground: 'Sales',
gradClassName: 'FSW-1',
favInstructor: michael
});
console.log(dwight.speak());
console.log(josh.demo('JavaScript'));
console.log(michael.grade('JavaScript', pam));
console.log(ryan.listSubjects());
console.log(ryan.PRAssignment('CSS'));
console.log(pam.sprintChallenge('React'));
console.log(jim.standUp('FSW-14'));
console.log(jim.debugCode(ryan, 'Express'));
console.log(jim.score(ryan));
console.log(ryan.graduate());