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
119 lines (103 loc) · 3.3 KB
/
Copy pathlambda-classes.js
File metadata and controls
119 lines (103 loc) · 3.3 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
class Person {
constructor (personProps) {
this.name = personProps.name;
this.age = personProps.age;
this.location = personProps.location;
this.gender = personProps.gender;
}
speak() {
console.log(`Hello my name is ${this.name}, I am from ${this.location}`)
}
}
class Instructor extends Person {
constructor(professorProperties) {
super(professorProperties);
this.specialty = professorProperties.specialty;
this.favLanguage = professorProperties.favLanguage;
this.catchPhrase = professorProperties.catchPhrase;
}
demo(subject) {
console.log(`Today we are learning about ${subject}`)
}
grade(student, subject) {
console.log(`${student.name} receives a perfect score on ${subject}`)
}
reviewSprint(student) {
if (student.grade < 70) {
let addOrSubtract = Math.random();
if (addOrSubtract < 0.5) {
student.grade = Math.round(student.grade - (addOrSubtract * 10));
}
else {
student.grade = Math.round(student.grade + (addOrSubtract * 10));
}
console.log(`The results are in...and ${student.name}'s current grade is ${student.grade}!`);
student.graduate(this);
}
else {
console.log(`No more Sprints! ${student.name} is ready to leave Lambda!`)
student.graduate(this);
}
}
}
class Student extends Person {
constructor(pupilProperties) {
super(pupilProperties);
this.previousBackground = pupilProperties.previousBackground;
this.className = pupilProperties.className;
this.favSubjects = pupilProperties.favSubjects;
this.grade = pupilProperties.grade;
}
listsSubjects() {
console.log(this.favSubjects.toString())
}
PRAssignment(subject) {
console.log(`${this.name} has submitted a PR for ${subject}`)
}
sprintChallenge(subject) {
console.log(`${this.name} has begun sprint challenge on ${subject}`)
}
graduate(instructor) {
if (this.grade >= 70) {
console.log(`${this.name} is officially a graduate of Lambda School!!`)
}
else {
console.log(`${this.name} is not quite ready to leave Lambda yet...${instructor.name} has to grade another Sprint!`);
instructor.reviewSprint(this);
}
}
}
class ProjectManager extends Instructor {
constructor(PMProperties) {
super(PMProperties);
this.gradClassName = PMProperties.gradClassName;
this.favInstructor = PMProperties.favInstructor;
}
standUp(channel) {
console.log(`${this.name} announces to ${channel}, @channel standy times!`)
}
debugsCode(student, subject) {
console.log(`${this.name} debugs ${student.name}'s code on ${subject}`)
}
}
const fred = new ProjectManager({
name: 'Fred',
location: 'Bedrock',
age: 37,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
})
const bruce = new Student({
name: 'Bruce',
location: 'Arizona',
age: 28,
gender: 'male',
favLanguage: 'HTML',
specialty: 'back-end',
catchPhrase: `Don't forget the bro-mies`,
favSubjects: ['HTML','CSS', 'JavaScript'],
grade: 50
})
bruce.graduate(fred);