This repository was archived by the owner on Jul 6, 2026. It is now read-only.
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
136 lines (117 loc) · 3.6 KB
/
Copy pathlambda-classes.js
File metadata and controls
136 lines (117 loc) · 3.6 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
// CODE here for your Lambda Classes
class Person {
constructor(attributes) {
this.name = attributes.name;
this.age = attributes.age;
this.location = attributes.location;
this.gender = attributes.gender;
}
speak() {
console.log(`Hello my name is ${this.name}, I am from ${this.location}.`)
}
}
class Instructor extends Person {
constructor(wiseAttributes) {
super(wiseAttributes);
this.specialty = wiseAttributes.specialty;
this.favLanguage = wiseAttributes.favLanguage;
this.catchPhrase = wiseAttributes.catchPhrase;
}
demo(subject) {
console.log(`Today we are learning about ${subject}.`)
}
grade(student, subject) {
console.log(`${student.name} receives a perfect score on ${subject}!`)
}
randomGrade(student) {
student.grade += Math.round(Math.random() * (10 - (-10)) + (-10));
console.log(`${this.name} grades ${student.name}'s assignment. ${student.name}'s overall grade is now: ${student.grade}%`)
}
}
class Student extends Person {
constructor(learningAttributes) {
super(learningAttributes);
this.previousBackground = learningAttributes.previousBackground;
this.favSubjects = learningAttributes.favSubjects;
this.grade = learningAttributes.grade;
}
listsSubjects() {
this.favSubjects.forEach(subject => console.log(subject));
}
PRAssignment(subject) {
console.log(`${this.name} has submitted a PR for ${subject}.`);
}
sprintChallenge(subject) {
console.log(`${this.name} has has begun sprint challenge on ${subject}.`);
}
graduate() {
if (this.grade > 70) {
console.log(`Congratulations, ${this.name} is now eligible to graduate!`)
} else {
console.log(`${this.name} is not ready to graduate. Continue with more assignments!`)
}
}
}
class ProjectManager extends Instructor {
constructor(pmAttributes) {
super(pmAttributes);
this.gradClassName = pmAttributes.gradClassName;
this.favInstructor = pmAttributes.favInstructor;
}
debugsCode(student,subject) {
console.log(`${this.name} debugs ${student.name}'s code on ${subject}.`);
}
standUp(channel) {
console.log(`${this.name} announces to ${channel}, @channel standy times!.`);
}
}
const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'Male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies!`
});
const pebbles = new Student({
name: 'Pebbles',
location: 'Bedrock',
age: 7,
gender: 'Female',
previousBackground: 'Python',
favSubjects: ['Data Analytics', 'Python', 'IoT'],
grade: 80
});
const wilma = new ProjectManager({
name: 'Wilma',
location: 'Bedrock',
age: 35,
gender: 'Female',
favLanguage: 'SQL',
specialty: 'Back-End',
catchPhrase: `Keep your hubby happy.`,
gradClassName: `WEB17`,
favInstructor: 'Josh Knell'
});
console.log(fred);
console.log(pebbles);
console.log(wilma);
pebbles.speak();
fred.demo('JavaScript II');
fred.grade(pebbles, 'JavaScript');
pebbles.listsSubjects();
pebbles.PRAssignment('Advanced CSS');
pebbles.sprintChallenge('JavaScript');
wilma.debugsCode(pebbles,'JavaScript III');
wilma.demo('JavaScript III');
wilma.standUp('WEB17');
console.log(pebbles.grade);
wilma.randomGrade(pebbles);
wilma.randomGrade(pebbles);
wilma.randomGrade(pebbles);
wilma.randomGrade(pebbles);
wilma.randomGrade(pebbles);
wilma.randomGrade(pebbles);
pebbles.graduate();
// THE END!