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
157 lines (141 loc) · 4.02 KB
/
Copy pathlambda-classes.js
File metadata and controls
157 lines (141 loc) · 4.02 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
// CODE here for your Lambda Classes
class Person {
constructor(personAttr) {
this.name = personAttr.name;
this.age = personAttr.age;
this.location = personAttr.location;
this.gender = personAttr.gender;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}.`;
}
}
class Instructor extends Person {
constructor(instructorAttr) {
super(instructorAttr);
this.specialty = instructorAttr.specialty;
this.faveLanguage = instructorAttr.faveLanguage;
this.catchPhrase = instructorAttr.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}.`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}.`;
}
studentGrade(student) {
const projectGrade = Math.floor(Math.random() * (-50 - 50));
let newStudentGrade = student.grade + projectGrade;
newStudentGrade;
return newStudentGrade;
}
}
class Students extends Person {
constructor(studentAttr) {
super(studentAttr);
this.previousBackground = studentAttr.previousBackground;
this.className = studentAttr.className;
this.favSubjects = studentAttr.favSubjects;
this.grade = studentAttr.grade;
}
listSubjects() {
return `${this.favSubjects}`;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}.`;
}
graduate() {
if (this.grade > 70) {
return `Student by the name of ${this.name}'s grade is ${
this.grade
}% not bad ${this.name} may move on the the next round `;
} else {
return `Sorry but ${this.name}'s grade is ${
this.grade
} and that is not enough to pass`;
}
}
}
class ProjectManager extends Instructor {
constructor(managerAttr) {
super(managerAttr);
this.gradClassName = managerAttr.gradClassName;
this.favInstructor = managerAttr.favInstructor;
this.favSubjects = managerAttr.favSubjects;
}
standUp(channel) {
return `${this.name} debugs ${channel}, @channel standy times `;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`;
}
}
const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'male',
faveLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `OOOH YEAH`
});
const Jill = new ProjectManager({
name: 'Jill',
location: 'Jamcity',
age: 25,
gender: 'female',
faveLanguage: 'Java',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`,
favSubjects: ['Design', 'HTML', 'CSS', 'LESS'],
favInstructor: 'Josh Knell',
gradClassName: 'Web_16'
});
const Jonas = new Students({
name: 'Jonas',
age: '37',
location: 'Florida',
gender: 'male',
previousBackground: 'Bartender',
className: 'web_17',
favSubjects: ['Design', 'HTML', 'CSS', 'LESS'],
grade: 100
});
console.log(fred.name);
console.log(fred.age);
console.log(fred.location);
console.log(fred.gender);
console.log(fred.specialty);
console.log(fred.faveLanguage);
console.log(fred.catchPhrase);
console.log(Jill.name);
console.log(Jill.age);
console.log(Jill.location);
console.log(Jill.gender);
console.log(Jill.specialty);
console.log(Jill.faveLanguage);
console.log(Jill.catchPhrase);
console.log(Jill.gradClassName);
console.log(Jill.favInstructor);
console.log(Jonas.name);
console.log(Jonas.age);
console.log(Jonas.location);
console.log(Jonas.gender);
console.log(Jonas.previousBackground);
console.log(Jonas.className);
console.log(Jonas.favSubjects);
console.log(fred.speak());
console.log(Jill.speak());
console.log(Jonas.speak());
console.log(fred.demo('Javascript'));
console.log(fred.grade(Jonas, 'Javascript'));
console.log(Jill.standUp('#getsome'));
console.log(Jill.debugsCode(Jonas, 'Javascript'));
console.log(Jonas.listSubjects());
console.log(Jonas.PRAssignment('Javascript'));
console.log(Jill.sprintChallenge('LESS'));
console.log((Jonas.grade = Jill.studentGrade(Jonas)));
console.log(Jonas.graduate());