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
155 lines (140 loc) · 3.61 KB
/
Copy pathlambda-classes.js
File metadata and controls
155 lines (140 loc) · 3.61 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
// CODE here for your Lambda Classes
class Person {
constructor (props) {
this.name = props.name;
this.age = props.age;
this.location = props.location;
}
speak () {
console.log(`Hello my name is ${this.name}, I am from ${this.location}. ${this.catchPhrase}`);
}
}
class Instructor extends Person {
constructor (props) {
super(props);
this.specialty = props.specialty;
this.favLanguage = props.favLanguage;
this.catchPhrase = props.catchPhrase;
}
demo (subject) {
console.log(`${this.name} says: Today we are learning about ${subject}`);
}
grade (student, subject) {
console.log(`${student.name} receives a perfect score on ${subject}`);
}
modifyGrade (student) {
console.log(`${this.name} is modifying ${student.name}\'s grade. Old grade: ${student.grade}.`)
let num = Math.ceil(Math.random() * (20 + 20)) - 20;
student.grade += num;
}
}
class Student extends Person {
constructor (props) {
super(props);
this.previousBackground = props.previousBackground;
this.className = props.className;
this.favSubjects = props.favSubjects;
this.grade = props.grade;
}
listsSubjects () {
console.log(`${this.name}\'s favorite subjects are:`)
this.favSubjects.map(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}`);
}
graduate () {
if (this.grade > 70) {
console.log(`New grade: ${this.grade}. ${this.name} is ready to graduate!`);
} else {
console.log(`New grade: ${this.grade}. ${this.name} can\'t graduate yet. Back to grading!`);
}
}
}
class TeamLead extends Instructor {
constructor (props) {
super(props);
this.gradClassName = props.gradClassName;
this.favInstructor = props.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}`);
}
}
// Instructors
const sheev = new Instructor({
name: 'Sheev Palpatine',
location: 'Naboo',
age: 80,
favLanguage: 'CSS',
specialty: 'Unlimited power',
catchPhrase: `Did you ever hear the tragedy of Darth Plagueis the Wise`
});
const obi = new Instructor({
name: 'Obi-Wan Kenobi',
location: 'High ground',
age: 37,
favLanguage: 'JavaScript',
specialty: 'The force',
catchPhrase: `Hello there`
});
// Students
const anakin = new Student({
name: 'Anakin Skywalker',
location: 'Tatooine',
age: 25,
previousBackground: 'Podracer',
className: 'Apprentice1',
favSubjects: [
'Padme',
'Immortality',
'Podracing',
'Sand'
],
grade: 80
});
const youngling = new Student({
name: 'Sors Bandeam',
location: 'Jedi Temple',
age: 10,
previousBackground: 'Newborn',
className: 'YC123',
favSubjects: [
'The Force',
'Planets & Systems',
'Techniques with Yoda'
],
grade: 60
});
// TLs
const mace = new TeamLead({
name: 'Mace Windu',
location: 'Jedi Council Chamber',
age: 40,
gradClassName: 'JC1',
favInstructor: 'Yoda'
});
const maul = new TeamLead({
name: 'Darth Maul',
location: 'Falling',
age: 30,
gradClassName: 'SL1',
favInstructor: 'Sheev Palpatine'
});
// Tests
sheev.speak();
obi.demo('HELLO THERE');
mace.standUp('#jedi_council');
maul.debugsCode(anakin, 'JavaScript');
anakin.listsSubjects();
youngling.sprintChallenge('Git for Jedi');
// Stretch Test
console.log('===== Stretch =====')
obi.modifyGrade(anakin);
anakin.graduate();