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
177 lines (154 loc) · 3.68 KB
/
Copy pathlambda-classes.js
File metadata and controls
177 lines (154 loc) · 3.68 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
// 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() {
console.log(`Hello my name is ${this.name}, I am from ${this.location}`)
}
}
let kurt = new Person({
name: 'Kurt',
age: 47,
location: 'Iowa',
gender: 'male'
})
console.log(kurt.location);
let marshall = new Person({
name: 'Marshall',
age: 45,
location: 'New Orleans',
gender: 'male'
})
marshall.speak();
class Instructor extends Person {
constructor(attrs) {
super(attrs)
this.specialty = attrs.specialty
this.favLanguage = attrs.favLanguage
this.catchPhrase = attrs.catchPhrase
}
demo(subject) {
console.log(`Today we are learning about ${subject}`)
}
grade(student, subject) {
console.log(`${student.name} receives a perfect score on ${subject}`)
}
adjustGrade(student) {
// add or subtract random num from 1 to 5
if (Math.random() < .5) {
student.grade += Math.floor(Math.random() * 5) + 1
} else {
student.grade -= Math.floor(Math.random() * 5) + 1
}
}
}
const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});
fred.demo('driving with feet');
let cam = new Instructor({
name: 'Cam',
location: 'Utah',
age: 31,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `shazam`
})
console.log(cam.catchPhrase);
class Student extends Person {
constructor(attrs) {
super(attrs)
this.previousBackground = attrs.previousBackground
this.className = attrs.className
this.favSubjects = attrs.favSubjects
this.grade = attrs.grade
}
listsSubjects() {
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}`);
}
// stretch instructions vague on how they want it to work.
graduate() {
if (this.grade >= 70) {
console.log(`${this.name} has graduated`);
} else {
console.log(`${this.name} is not ready`);
}
}
}
let me = new Student({
name: 'Adam',
location: 'Earth',
age: 70,
gender: 'male',
previousBackground: 'tech support',
className: 'webpt4',
favSubjects: ['js', 'git', 'github', 'terminal'],
grade: 77
})
let joe = new Student({
name: 'Joe',
location: 'Ohio',
age: 30,
gender: 'male',
previousBackground: 'sales',
className: 'webpt2',
favSubjects: ['html', 'css'],
grade: 67
})
me.speak();
me.listsSubjects()
me.PRAssignment('JavaScript-IV')
me.sprintChallenge('javascript')
class ProjectManager extends Instructor {
constructor(attrs) {
super(attrs)
this.gradClassName = attrs.gradClassName
this.favInstructor = attrs.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}`)
}
}
let bob = new ProjectManager({
name: 'Bob',
location: 'Massachusetts',
age: 32,
gender: 'male',
gradClassName: 'CS1',
favInstructor: "Cam"
})
bob.debugsCode(joe, 'Node')
let sally = new ProjectManager({
name: 'Sally',
location: 'Texas',
age: 25,
gender: 'female',
gradClassName: 'webpt3',
favInstructor: "Dan"
})
sally.standUp("webpt4_sally")
sally.demo("python")
while (joe.grade < 70) {
bob.adjustGrade(joe)
joe.graduate();
}