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
133 lines (117 loc) · 3.77 KB
/
Copy pathlambda-classes.js
File metadata and controls
133 lines (117 loc) · 3.77 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
// CODE here for your Lambda Classes
// people --> instructors, studens, project managers
class People {
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}`;
}
}
class Instructor extends People {
constructor(attributes) {
super(attributes);
this.specialty = attributes.specialty;
this.favLanguage = attributes.favLanguage;
this.catchPhrase = attributes.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject, grade, effort) {
let randomInt = Math.floor(Math.random() * 11); // 0 -> 10 Points
if (effort) {
grade += randomInt;
return `${student} is working hard on ${subject}. I will add ${randomInt} points to his score. ${grade}`;
} else {
grade -= randomInt;
return `${student} is NOT working hard on ${subject}. I will subtract ${randomInt} points to his score. ${grade}`;
}
}
}
class Student extends People {
constructor(attributes) {
super(attributes);
this.previousBackground = attributes.previousBackground;
this.className = attributes.className;
this.favSubjects = attributes.favSubjects;
this.grade = attributes.grade;
this.isWorkingHard = attributes.isWorkingHard;
}
listsSubjects() {
return `${this.favSubjects}`;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`;
}
graduate() {
if (this.grade < 70) {
let pointsNeeded = 70 - this.grade;
return `Your current grade is ${this.grade}. You need ${pointsNeeded} points to graduate`;
} else {
return `CONGRATS!!!`;
}
}
}
class ProjectManagers extends Instructor {
constructor(attributes) {
super(attributes);
this.gradClassName = attributes.gradClassName;
this.favInstructor = attributes.favInstructor;
}
standUp(channel) {
return `${this.name} announces to ${channel}, @channel standy times!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student}'s code on ${subject}`;
}
}
const jeor = new Instructor({
name: 'Jeor Mormont',
location: 'Castle Black',
age: 60,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the your oath.`
});
const jon = new Student({
name: 'Jon Snow',
location: 'Winterfell',
age: 22,
gender: 'male',
previousBackground: 'none',
className: 'CS16',
favSubjects: ['Python', 'C', 'JavaScript'],
grade: 65,
isWorkingHard: false,
});
const aemon = new ProjectManagers({
name: 'Aemon Targaryen',
location: 'Castle Black',
age: 100,
gender: 'male',
gradClassName: 'CS1',
favInstructor: 'Maester Luwin'
});
// Instructor
console.log(jeor.speak());
console.log(jeor.demo('Object Oriented Programming'));
console.log(jeor.grade(jon.name, 'JavaScript IV', jon.grade, jon.isWorkingHard));
// Student
console.log(jon.speak());
console.log(jon.listsSubjects());
console.log(jon.PRAssignment('JavaScript IV'));
console.log(jon.sprintChallenge('JavaScript Fundamentals'));
console.log(jon.graduate());
// PM
console.log(aemon.speak());
console.log(aemon.standUp('FSW15'));
console.log(aemon.debugsCode('Jon Snow', 'JavaScript I'));
console.log(jeor.grade(jon.name, 'JavaScript IV', jon.grade, jon.isWorkingHard));