Repository navigation
Expand file tree
/
Copy pathlambda-classes.js
More file actions
167 lines (153 loc) · 4.06 KB
/
Copy pathlambda-classes.js
File metadata and controls
167 lines (153 loc) · 4.06 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
// CODE here for your Lambda Classes
class Person{
constructor(personOptions){
this.name = personOptions.name;
this.age = personOptions.age;
this.location = personOptions.location;
this.gender = personOptions.gender;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
class Instructor extends Person{
constructor(instructorOptions) {
super(instructorOptions);
this.specialty = instructorOptions.specialty;
this.favLanguage = instructorOptions.favLanguage;
this.catchPhrase = instructorOptions.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`;
}
changeGrade(student){
let plusOrMinus = Math.random() < 0.5 ? -1 : 1;
let points = Math.floor(Math.random() * 20);
let randomPoints = points * plusOrMinus;
return student.grade + randomPoints;
}
}
class Student extends Person{
constructor(studentOptions) {
super(studentOptions);
this.previousBackground = studentOptions.previousBackground;
this.className = studentOptions.className;
this.favSubjects = studentOptions.favSubjects;
}
listsSubjects(){
this.favSubjects.forEach(element => {
console.log(element);
});
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun a sprint challenge on ${subject}`;
}
}
class ProjectManager extends Instructor{
constructor(PMOptions) {
super(PMOptions);
this.gradClassName = PMOptions.gradClassName;
this.favInstructor = PMOptions.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}`;
}
}
//////////////////////////////////////////////////////////////
const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});
const frodo = new Instructor({
name: 'Frodo',
location: 'the Shire',
age: 33,
gender: 'male',
favLanguage: 'Python',
specialty: 'Back-end',
catchPhrase: `Gandalf made me do it`
});
const blossom = new Student({
name: 'Blossom',
location: 'Townsville',
age: 12,
gender: 'female',
previousBackground: 'superhero',
className: 'CS12',
favSubjects: [
'HTML',
'CSS',
]
});
const bubbles = new Student({
name: 'Bubbles',
location: 'Townsville',
age: 13,
gender: 'female',
previousBackground: 'superhero',
className: 'CS13',
favSubjects: [
'CSS',
'Javascript',
]
});
const buttercup = new Student({
name: 'Buttercup',
location: 'Townsville',
age: 11,
gender: 'female',
previousBackground: 'superhero',
className: 'CS14',
favSubjects: [
'Bootstrap',
'Javascript',
]
});
const mia = new ProjectManager({
name: 'Mia',
location: 'Nashville',
age: 22,
gender: 'female',
favLanguage: 'Ruby',
specialty: 'Front-end',
catchPhrase: 'Eyebrows on fleek',
gradClassName: 'CS1',
favInstructor: 'Sean'
});
const james = new ProjectManager({
name: 'James',
location: 'Atlanta',
age: 27,
gender: 'male',
favLanguage: 'C#',
specialty: 'Full-Stack',
catchPhrase: `I'm Batman`,
gradClassName: 'CS2',
favInstructor: 'Caleb'
});
// console.log(fred.specialty);
// console.log(frodo.catchPhrase);
// console.log(blossom.className);
//console.log(bubbles.listsSubjects());
// console.log(blossom.listsSubjects());
// console.log(buttercup.name);
// console.log(mia.gradClassName);
//console.log(james.debugsCode(bubbles, 'Bootstrap'));
// console.log(fred.speak());
//console.log(blossom.sprintChallenge('CSS'));
//console.log(mia.standUp('cs12_help'));
//console.log(fred.changeGrade(buttercup));