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
129 lines (116 loc) · 3.45 KB
/
Copy pathlambda-classes.js
File metadata and controls
129 lines (116 loc) · 3.45 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
// CODE here for your Lambda Classes
class Person {
constructor(personInfo) {
this.name = personInfo.name;
this.location = personInfo.location;
this.gender = personInfo.gender;
this.age = personInfo.age;
}
speak() {
console.log(`Hello my name is ${this.name}, I am from ${this.location}`);
}
}
class Instructor extends Person {
constructor(instructorInfo) {
super(instructorInfo);
this.specialty = instructorInfo.specialty;
this.favLanguage = instructorInfo.favLanguage;
this.catchPhrase = instructorInfo.catchPhrase;
}
demo(subject) {
console.log(`Today we are learning about ${subject}`);
}
grade(studentObj, subject) {
console.log(`${studentObj.name} receives a perfect score on ${subject}`);
}
changeScore(grade) {
const randomPoints = Math.floor(Math.random() * (5 - 1 + 1)) + 1;
const randomGrading = Math.random();
if(randomGrading >= .5) {
grade += randomPoints;
}
else {
grade -= randomPoints;
}
return grade;
}
}
class Student extends Person {
constructor(studentInfo) {
super(studentInfo);
this.previousBackground = studentInfo.previousBackground;
this.className = studentInfo.className;
this.favSubjects = studentInfo.favSubjects;
this.grade = studentInfo.grade;
}
listsSubjects() {
for (let i = 0; i < this.favSubjects.length; i++) {
console.log(this.favSubjects[i]);
}
}
PRAssignment(subject) {
console.log(`${this.name} has submitted a PR for ${subject}`);
}
sprintChallenge(subject) {
console.log(`${this.name} has begun sprint challenge on ${subject}`);
}
graduation() {
console.log(this.grade > 70 ? `You have passed!` : `You need to keep studying!`);
}
}
class ProjectManagers extends Instructor {
constructor(pmInfo) {
super(pmInfo);
this.gradClassName = pmInfo.gradClassName;
this.favInstructor = pmInfo.favInstructor;
}
standUp(channel) {
console.log(`${this.name} announces to ${channel}, @channel standy times!`);
}
debugsCode(studentObj, subject) {
console.log(`${this.name} debugs ${studentObj.name}'s code on ${subject}`);
}
}
const turner = new Instructor({
name: 'Turner',
location: 'Arizona',
age: 32,
gender: 'male',
favLanguage: 'Python',
specialty: 'Back-end',
catchPhrase: `I hate pythons but love Python.`
});
const simon = new Student({
name: 'Simon',
location: 'Georgia',
gender: 'male',
age: 40,
favSubjects: ['Javascript', 'Mathmatics'],
previousBackground: "Some JS experience",
className: "CS11",
grade: 89,
});
const josh = new ProjectManagers({
name: 'Josh',
location: 'Alabama',
gender: 'male',
specialty: 'front-end',
favLanguage: 'Javascript',
catchPhrase: 'It\'s mindblowing',
gradClassName: 'CS11',
favInstructor: 'Josh Knell',
});
//Instructor tests
turner.speak();
turner.demo('HTML');
turner.grade(simon,'Javascript');
// Simon's grade is 89 as the original and will change 1 to 5 points in either direction
console.log(turner.changeScore(simon.grade));
//Student tests
simon.listsSubjects();
simon.PRAssignment('Javascript IV');
simon.sprintChallenge('Super Javascript');
simon.graduation();
//PM tests
josh.standUp('CS11-Josh');
josh.debugsCode(simon, 'HTML');