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
154 lines (143 loc) · 4.2 KB
/
Copy pathlambda-classes.js
File metadata and controls
154 lines (143 loc) · 4.2 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
// CODE here for your Lambda Classes
class Person {
constructor(personInfo) {
this.name = personInfo.name;
this.age = personInfo.age;
this.location = personInfo.location;
this.gender = personInfo.gender;
};
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
};
class Instructor extends Person {
constructor(instInfo) {
super(instInfo);
this.specialty = instInfo.specialty;
this.favLanguage = instInfo.favLanguage;
this.catchPhrase = instInfo.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(Student, subject) {
return `${Student.name} recieves a perfect score on ${subject}`;
}
gradeAlter(Student) {
let alterArr = ['+', '-'];
let score = Math.round(Math.random() * 10);
let gradeScore = alterArr[Math.round(Math.random())];
if (gradeScore === '+') {
return `${Student.name} is killin it with a ${Math.round(Student.grade += score)} in the class`;
} else {
return `${Student.name} aint doing so hot with a ${Math.round(Student.grade -= score)} in the class`;
}
}
};
class Student extends Person {
constructor(studInfo) {
super(studInfo);
this.previousBackround = studInfo.previousBackround;
this.className = studInfo.className;
this.favSubjects = studInfo.favSubjects;
this.grade = studInfo.grade;
}
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() {
let gen = '';
if(this.gender === 'male'){
gen = 'him';
}
else{
gen = 'her';
}
if (this.grade >= 70) {
return `${this.name} is ready to graduate!!!!!`
} else {
return `${this.name} has failed everyone who has ever cared about ${gen}`;
}
}
}
class ProjectManager extends Instructor {
constructor(projInfo) {
super(projInfo);
this.gradClassName = projInfo.gradClassName;
this.favInstructor = projInfo.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 josh = new Instructor({
name: 'Josh',
age: '35',
location: 'Over there',
gender: 'male',
specialty: 'Front-End',
favLanguage: 'JavaScript, bootstrap',
catchPhrase: 'I am here, and obey'
});
const frodo = new Instructor({
name: 'Bilbo',
age: '100',
location: 'The Shire',
gender: 'male',
specialty: 'Ring delivery',
favLanguage: 'Westron',
catchPhrase: 'The ring is mine'
});
const libby = new Student({
name: 'Libby',
age: 'That one',
location: 'Foresty place',
gender: 'female',
previousBackround: 'lion taming',
className: 'CS11',
favSubjects: 'Inline-block, lion taming',
grade: 70,
});
const eric = new Student({
name: 'eric',
age: 'That one',
location: 'That place',
gender: 'male',
previousBackround: 'hockey player',
className: 'CS11',
favSubjects: 'Javascript',
grade: 70,
});
const ben = new ProjectManager({
name: 'Ben',
age: 'That number',
location: 'Way over there',
gender: 'male',
specialty: 'react',
favLanguage: 'react',
catchPhrase: 'Time to flamingle!',
gradClassName: 'CS(That one)',
favInstructor: 'Josh'
})
console.log(josh.demo('java'));
console.log(josh.grade(libby, 'arrayz'));
console.log(frodo.demo('bootstrap'));
console.log(frodo.grade(eric, 'react'));
console.log(libby.listsSubjects());
console.log(libby.PRAssignment('prototype'));
console.log(libby.sprintChallenge('classes'));
console.log(ben.standUp('cs11'));
console.log(ben.debugsCode(libby, 'classes'));
console.log(josh.gradeAlter(libby));
console.log(josh.gradeAlter(eric));
console.log(libby.graduate());
console.log(eric.graduate());