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
140 lines (125 loc) · 4.07 KB
/
Copy pathlambda-classes.js
File metadata and controls
140 lines (125 loc) · 4.07 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
// CODE here for your Lambda Classes
// Base class
class Person {
constructor(attributes) {
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
this.gender = attributes.gender;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
// Instructor class
class Instructor extends Person {
constructor(instAttributes) {
super(instAttributes);
this.specialty = instAttributes.specialty;
this.favLanguage = instAttributes.favLanguage;
this.catchPhrase = instAttributes.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`;
}
addPoints(student) {
return `${student.name} gets points of ${Math.floor(Math.random() * 6) + student.score}`;
}
subtractPoints(student) {
return `${student.name} gets points of ${student.score - Math.floor(Math.random() * 6)}`;
}
}
// Student class
class Student extends Person {
constructor(stuAttributes) {
super(stuAttributes);
this.previousBackground = stuAttributes.previousBackground;
this.className = stuAttributes.className;
this.favSubjects = stuAttributes.favSubjects;
this.score = stuAttributes.score;
}
listsSubjects() {
return `Favorite subjects are: ${this.favSubjects.join(' --')}`;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun spring challenge on ${subject}`;
}
doesStudentGraduate() {
if(this.score > 70) {
return `${this.name} is ready to graduate from Lambda School`;
} else {
return `${this.name} should keep doing assignments to increase ${this.name}'s score`;
}
}
}
// Project Manager class
class ProjectManagers extends Instructor {
constructor(pmAttributes) {
super(pmAttributes);
this.gradClassName = pmAttributes.gradClassName;
this.favInstructor = pmAttributes.favInstructor;
}
standUp(slackChannel) {
return `${this.name} announces to ${slackChannel}, @channel standy times!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
const richard = new Instructor({
name: 'Richard Beldin',
age: 35,
location: 'San Francisco',
gender: 'Male',
specialty: 'Data Visualization Development',
favLanguage: "Python",
catchPhrase: 'Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live',
});
const screech = new Student({
name: 'Screech Powers',
age: 17,
location: 'Silicon Valley',
gender: 'Male',
previousBackground: 'Physics',
className: 'FSW 8',
favSubjects: ['HTML', 'CSS', 'JavaScript', 'Python', 'SQL'],
score: 100,
});
const zack = new ProjectManagers({
name: 'Zack Morris',
age: 18,
location: 'Silicon Valley',
gender: 'Male',
gradClassName: 'FSW 4',
favInstructor: 'Richard',
});
console.log(richard.name);
console.log(richard.specialty);
console.log(richard.favLanguage);
console.log(richard.catchPhrase);
console.log(richard.demo('Express'));
console.log(richard.grade(screech, 'Redux'));
console.log(screech.age);
console.log(screech.name);
console.log(screech.listsSubjects());
console.log(screech.PRAssignment('django'));
console.log(screech.sprintChallenge('GraphQL'));
console.log(zack.location);
console.log(zack.gradClassName);
console.log(zack.favInstructor);
console.log(zack.standUp('zack_FSW8'));
console.log(zack.debugsCode(screech, 'Express'));
console.log(screech.score);
console.log(richard.addPoints(screech));
console.log(zack.subtractPoints(screech));
richard.subtractPoints(screech);
zack.addPoints(screech);
zack.addPoints(screech);
zack.subtractPoints(screech);
console.log(screech.doesStudentGraduate());