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 (126 loc) · 3.86 KB
/
Copy pathlambda-classes.js
File metadata and controls
136 lines (126 loc) · 3.86 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(props) {
this.name = props.name;
this.age = props.age;
this.location = props.location;
}
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
class Instructor extends Person {
constructor(props) {
super(props);
this.speciality = props.speciality;
this.favLanguage = props.favLanguage;
this.catchPhrase = props.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`;
}
changeGrade(grade) {
return Math.floor(Math.random(grade) * 100);
}
}
class Student extends Person {
constructor(props) {
super(props);
this.previousBackground = props.previousBackground;
this.className = props.className;
this.favSubject = props.favSubject;
this.grade = props.grade;
}
listSubjects(favSubject) {
return favSubject;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`;
}
graduate(changeGrade) {
if (changeGrade >= 70) {
return "Yes!";
} else {
return "Nope";
}
}
}
class ProjectManager extends Instructor {
constructor(props) {
super(props);
this.gradClass = props.gradClass;
this.favInstructor = props.favInstructor;
}
standUp(channel) {
return `${this.name} announces to ${channel}, @channel standy times`;
}
debugCode(student, subject) {
return `${this.name} debugs ${student}'s code on ${subject}`;
}
}
const fred = new Instructor({
name: "Fred",
location: "Bedrock",
age: 37,
favLanguage: "JavaScript",
catchPhrase: "Don't forget the homies"
});
const wilma = new Instructor({
name: "Wilma",
location: "Bedrock",
age: 39,
favLanguage: "CSS",
catchPhrase: "There's no crying in CSS"
});
const pebbles = new Student({
name: "Pebbles",
previousBackground: "Dinorider",
className: "Slate Rock and Gravel",
favSubject: ["HTML", "CSS", "JavaScript"],
grade: fred.changeGrade()
});
const bambam = new Student({
name: "Bambam",
previousBackground: "Rock Pounder",
className: "Loyal Order of Water Buffalos",
favSubject: ["HTML", "CSS", "JavaScript"],
grade: fred.changeGrade()
});
const barney = new ProjectManager({
name: "Barney",
gradClass: "Amenable",
favInstructor: "Fred"
});
const slate = new ProjectManager({
name: "Mr. Slate",
gradClass: "Baby T-Rex",
favInstructor: "Rockhead Sylvester"
});
console.log(`/----------Instructors----------/`);
console.log(`Instructor ${fred.name}'s favorite language is ${fred.favLanguage}.`);
console.log(`Instructor ${wilma.name} likes to say: ${wilma.catchPhrase}`);
console.log(fred.demo("JavaScript"));
console.log(wilma.demo("CSS"));
console.log(fred.grade(bambam, bambam.favSubject[0]));
console.log(wilma.grade(pebbles, pebbles.favSubject[1]));
console.log(`/----------Students----------/`);
console.log(`${pebbles.name} used to be a ${pebbles.previousBackground}`);
console.log(`${bambam.name} is in the ${bambam.className}`);
console.log(pebbles.PRAssignment("Objects"));
console.log(bambam.sprintChallenge("Array methods"));
console.log(`/----------Program Managers----------/`);
console.log(`${barney.name} is from the ${barney.gradClass} class`);
console.log(`${slate.name}'s favorite instructor is ${slate.favInstructor}`);
console.log(barney.standUp("Yabba Dabba Do"));
console.log(slate.debugCode(pebbles.name, pebbles.favSubject[2]));
console.log(`/----------Stretch----------/`);
console.log(`Pebbles' grade: ${pebbles.grade}`);
console.log(`Does ${pebbles.name} graduate? ${pebbles.graduate(pebbles.grade)}`);
console.log(`Bambam's grade: ${bambam.grade}`);
console.log(`Does ${bambam.name} graduate? ${bambam.graduate(bambam.grade)}`);