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
107 lines (97 loc) · 3.01 KB
/
Copy pathlambda-classes.js
File metadata and controls
107 lines (97 loc) · 3.01 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
// CODE here for your Lambda Classes
class Person{
constructor(personAttributes){
this.name = personAttributes.name;
this.age = personAttributes.age;
this.location = personAttributes.location;
}
speak(){
return `Hello my name is ${this.name}, I am from ${this.location}`;
}
}
class Instructor extends Person{
constructor(instructorAttributes){
super(instructorAttributes);
this.gender = instructorAttributes.gender;
this.favLanguage = instructorAttributes.favLanguage;
this.specialty = instructorAttributes.specialty;
this.catchPhrase = instructorAttributes.catchPhrase;
}
demo(subject){
return `Today we are learning about ${subject}`
}
grade(student, subject){
return `${student.name} receives a perfect score on ${subject}`
}
manuplateGrade(student, refactor, randNum = Math.random() * 50){
if(!student.grade) return 'Student has no grade';
if(refactor.toLowerCase() === 'add'){
return student.grade + randNum;
}else if(refactor.toLowerCase() === 'subtract') {
return student.grade - randNum;
}
else {
return 'Please type add or subtract!';
}
}
}
class Student extends Person{
constructor(studentAttributes){
super(studentAttributes);
this.previousBackground = studentAttributes.previousBackground;
this.className = studentAttributes.className;
this.favSubjects = studentAttributes.favSubjects;
this.grade = 99;
}
listsSubjects(){
this.favSubjects.forEach(function(element){
console.log(element);
}) ;
}
PRAssignment(subject){
return `${this.name} has submitted a PR for ${subject}`;
}
sprintChallenge(subject){
return `${this.name} has begun spring challenge on ${subject}`
}
graduate(){
if(this.grade > 70){
return "graduate!!!!".toUpperCase();
}else{
this.grade += 10;
}
}
}
class ProjectManagers extends Instructor{
constructor(pmAttributes){
super(pmAttributes);
this.gradClassName = pmAttributes.gradClassName;
this.favInstructor = pmAttributes.favInstructor;
}
standUp(channel){
return `${this.name} announces to ${channel}, @channel standy times!`
}
debugsCode(student, subject){
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}
}
const fred = new Student({
name: 'Fred',
age: 37,
location: 'Bedrock',
previousBackground: 'photographer',
className: 'cs11',
favSubjects: ['React', 'Redux', 'less', 'cryptography']
});
console.log(fred.graduate());
const freds = new Instructor({
name: 'Fred2',
location: 'Bedrock',
age: 30,
gender: 'male',
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});
console.log(freds.manuplateGrade(fred, 'subtract', 50));
console.log(fred.graduate());