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
130 lines (113 loc) · 3.4 KB
/
Copy pathlambda-classes.js
File metadata and controls
130 lines (113 loc) · 3.4 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
// Base class
class Person {
constructor(personAtts) {
this.name = personAtts.name;
this.age = personAtts.age;
this.location = personAtts.location;
this.gender = personAtts.gender;
}
speak() {
return console.log(`Hello my name is ${this.name}, I am from ${this.location}.`)
}
}
class Instructor extends Person {
constructor(instructorAtts) {
super(instructorAtts);
this.speciality = instructorAtts.speciality;
this.favLanguage = instructorAtts.favLanguage;
this.catchPhrase = instructorAtts.catchPhrase;
}
demo(subject) {
return console.log(`Today we are learning about ${subject}`)
}
grade(student, subject) {
return console.log(`${student.name} receives a perfect score on ${subject}`)
}
}
class Student extends Person {
constructor(studentAtts) {
super(studentAtts);
this.previousBackground = studentAtts.previousBackground;
this.className = studentAtts.className;
this.favSubjects = studentAtts.favSubjects;
}
listsSubjects() {
return this.favSubjects.forEach(subject => {
console.log(subject)
});
}
PRAssignment(subject) {
return console.log(`${this.name} has submitted a PR for ${subject}`)
}
sprintChallenge(subject) {
return console.log(`${this.name} has begun sprint challenge on ${subject}`)
}
}
class ProjectManager extends Instructor {
constructor(pmAtts) {
super(pmAtts);
this.gradClassName = pmAtts.gradClassName;
this.favInstructor = pmAtts.favInstructor;
}
standUp(channel) {
return console.log(`${this.name} announces to ${channel}, @channel standy times!`)
}
debugsCode(student, subject) {
return console.log(`${this.name} debugs ${student.name}'s code on ${subject}`)
}
}
const personRandom = new Person({
name: 'Random Person',
location: 'New York',
age: 18,
gender: 'male',
})
const instructorRandom = new Instructor({
name: 'Random Instructor',
location: 'Mississippi',
age: 40,
gender: 'male',
specialty: 'React',
favLanguage: 'JS',
catchPhrase: 'This is a catch phrase',
subject: 'JS Fundamentals',
student: {
name: 'this a student name',
},
});
const randomStudent = new Student({
name: 'Random Student',
location: 'Florida',
age: 24,
gender: 'female',
previousBackground: 'Material Science',
className: 'WEB17',
favSubjects: ['Math', 'Computer Science', 'History'],
});
const randomPM = new ProjectManager({
name: 'Random Project Manager',
location: 'California',
age: 25,
gender: 'male',
gradClassName: 'WEB17',
favInstructor: 'Knell',
})
console.log(personRandom);
console.log(instructorRandom);
console.log(randomStudent);
console.log(randomPM);
personRandom.speak();
instructorRandom.demo('React');
instructorRandom.grade({
name: 'Student Name'
}, 'JavaScript Sprint');
console.log(`Instructor catch phrase: ${instructorRandom.catchPhrase}`);
randomStudent.listsSubjects();
randomStudent.PRAssignment('JavaScript');
randomStudent.sprintChallenge('JavaScript');
console.log(`Student previous background: ${randomStudent.previousBackground}`);
randomPM.standUp('web17');
randomPM.debugsCode({
name: 'Random student'
}, 'JavaScript');
console.log(`PM's favorite instructor: ${randomPM.favInstructor}`);