Repository navigation
Expand file tree
/
Copy pathlambda-classes.js
More file actions
104 lines (96 loc) · 2.92 KB
/
Copy pathlambda-classes.js
File metadata and controls
104 lines (96 loc) · 2.92 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
// 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() {
return `Hello, my name is ${this.name}, I am from ${this.location}`;
}
}
class Instructors extends Person{
constructor(instAtt){
super(instAtt);
this.specialty = instAtt.specialty;
this.favLanguage = instAtt.favLanguage;
this.catchPhrase = instAtt.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`;
}
}
class Student extends Person {
constructor(studAtt){
super(studAtt);
this.previousBackground = studAtt.previousBackground;
this.className = studAtt.className;
this.favSubjects = studAtt.favSubjects;
this.grade = studAtt.grade;
}
listsSubjects() {
return this.favSubjects;
}
PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject) {
return `${this.name} has begun sprint challenge on ${subject}`;
}
graduate() {
if (this.grade > 70) {
return `${this.name} has graduated from Lambda School with a grade of ${this.grade}!`;
}
}
}
class ProjectManager extends Instructors {
constructor(pmAtt){
super(pmAtt);
this.gradClassName = pmAtt.gradClassName;
this.favInstructor = pmAtt.favInstructor;
}
standUp(slackChannel) {
return `${this.name} announces to ${slackChannel} @channel standy times!`;
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
const Alexandra = new Student({
'name': 'Alexandra',
'age': 26,
'location': 'Philadelphia',
'gender': 'Female',
'previousBackground': 'none',
'className': 'CS13',
'favSubjects': ['JavaScript', 'LESS', 'CSS flexbox'],
'grade': 90
});
const Dave = new ProjectManager({
'name': 'Dave',
'age': 32,
'location': 'Toledo',
'gender': 'Male',
'gradClassName': 'CS8',
'favInstructor': 'Sean'
});
const Toby = new Instructors({
'name': 'Toby',
'age': 36,
'location': 'Miami',
'gender': 'Male',
'specialty': 'coming up with fun challenges',
'favLanguage': 'JavaScript',
'catchPhrase': 'fingers on keyboards!'
});
console.log(Alexandra.PRAssignment('.this keyword'));
console.log(Dave.standUp('#cs13-team-dave'));
console.log(Dave.debugsCode(Alexandra, '.this keyword'));
console.log(Toby.demo('JS class syntax'));
console.log(Toby.grade(Alexandra, 'JS class syntax'));
console.log(Alexandra.graduate());
console.log(`${Alexandra.favSubjects[0]}, ${Alexandra.favSubjects[1]}, ${Alexandra.favSubjects[2]}`);