|
1 | | -// CODE here for your Lambda Classes |
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | +// borrowed from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random |
| 5 | +function getRandomInt(min, max) { |
| 6 | + min = Math.ceil(min); |
| 7 | + max = Math.floor(max); |
| 8 | + return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive |
| 9 | +} |
| 10 | + |
| 11 | +class Person { |
| 12 | + constructor(attributes) { |
| 13 | + this.name = attributes.name; |
| 14 | + this.age = attributes.age; |
| 15 | + this.location = attributes.location; |
| 16 | + } |
| 17 | + speak() { |
| 18 | + return `Hello my name is ${this.name}, I am from ${this.location}`; |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +class Instructor extends Person { |
| 25 | + constructor(instructorAttributes) { |
| 26 | + super(instructorAttributes); |
| 27 | + this.specialty = instructorAttributes.specialty; |
| 28 | + this.favLanguage = instructorAttributes.favLanguage; |
| 29 | + this.catchPhrase = instructorAttributes.catchPhrase; |
| 30 | + } |
| 31 | + demo(subject) { |
| 32 | + return `Today we are learning about ${subject}`; |
| 33 | + } |
| 34 | + grade(student, subject) { |
| 35 | + return `${student.name} receives a perfect score on ${subject}`; |
| 36 | + } |
| 37 | + |
| 38 | + giveActualGrade(student) { |
| 39 | + return `${student.name} is getting a ${student.grade} at Lambda School`; |
| 40 | + } |
| 41 | + mark(student) { |
| 42 | + let randomMark = getRandomInt(-10, 11); |
| 43 | + student.grade+= randomMark; |
| 44 | + return `${student.name} was marked ${randomMark} points. ${student.name}'s grade is now ${student.grade}` |
| 45 | + } |
| 46 | + |
| 47 | +} |
| 48 | + |
| 49 | + |
| 50 | +class Student extends Person { |
| 51 | + constructor(studentAttributes) { |
| 52 | + super(studentAttributes); |
| 53 | + this.previousBackground = studentAttributes.previousBackground; |
| 54 | + this.className = studentAttributes.className; |
| 55 | + this.favSubjects = studentAttributes.favSubjects; |
| 56 | + this.grade = studentAttributes.grade; |
| 57 | + } |
| 58 | + listsSubjects() { |
| 59 | + let endString = ''; |
| 60 | + for (let i = 0; i < this.favSubjects.length; i++) { |
| 61 | + endString += this.favSubjects[i] + ' '; |
| 62 | + } |
| 63 | + return endString; |
| 64 | + } |
| 65 | + PRAssignment(subject) { |
| 66 | + return `${this.name} has submitted a PR for ${subject}`; |
| 67 | + } |
| 68 | + sprintChallenge(subject) { |
| 69 | + return `${this.name} has begun sprint challenge on ${subject}`; |
| 70 | + } |
| 71 | + graduate() { |
| 72 | + if (this.grade >= 70) { |
| 73 | + return `${this.name} has graduated!` |
| 74 | + } else return `${this.name}'s grade is too low. They need to do more work before they can graduate` |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +class ProjectManager extends Instructor { |
| 79 | + constructor(projectManagerAttributes) { |
| 80 | + super(projectManagerAttributes); |
| 81 | + this.gradClassName = projectManagerAttributes.gradClassName; |
| 82 | + this.favInstructor = projectManagerAttributes.favInstructor; |
| 83 | + } |
| 84 | + standUp(channel) { |
| 85 | + return `${this.name} announces to ${channel}, @channel standy times!`; |
| 86 | + } |
| 87 | + debugsCode(student, subject) { |
| 88 | + return `${this.name} debugs ${student.name}'s code on ${subject}`; |
| 89 | + } |
| 90 | + |
| 91 | +} |
| 92 | + |
| 93 | +const dan = new Instructor({ |
| 94 | + name: 'Dan', |
| 95 | + age: 'Infinity', |
| 96 | + location: 'Denver', |
| 97 | + specialty: 'Relentless Debugger', |
| 98 | + favLanguage: 'JavaScript, Python, Elm, ReasonML, SmallTalk, Haskell, C#, Java, Rust, Go, Ruby, Crystal, Elixir, Lua, and Julia', |
| 99 | + catchPhrase: 'If you can do the thing, you can get paid to do the thing!', |
| 100 | +}); |
| 101 | + |
| 102 | +const matthew = new Instructor({ |
| 103 | + name: 'Matthew', |
| 104 | + age: 29, |
| 105 | + location: 'Toronto', |
| 106 | + specialty: 'eating donuts', |
| 107 | + favLanguage: 'French', |
| 108 | + catchPhrase: 'ne pas subir', |
| 109 | +}); |
| 110 | + |
| 111 | + const isaiah = new Student({ |
| 112 | + name: 'Isaiah', |
| 113 | + age: 18, |
| 114 | + location: 'Florida', |
| 115 | + previousBackground: 'High School last month', |
| 116 | + className: 'Web21', |
| 117 | + grade: 100, |
| 118 | + favSubjects: ['Html', 'CSS', 'JavaScript'], |
| 119 | +}); |
| 120 | + const kevin = new Student({ |
| 121 | + name: "Kevin", |
| 122 | + age: 28, |
| 123 | + location: "California", |
| 124 | + previousBackground: "Table Games Dealer", |
| 125 | + className: "WEB21", |
| 126 | + grade: 95, |
| 127 | + favSubjects: ['Html', 'CSS', 'JavaScript'], |
| 128 | +}); |
| 129 | + const nisa = new Student({ |
| 130 | + name: 'Nisa', |
| 131 | + age: 25, |
| 132 | + location: 'Ohio', |
| 133 | + previousBackground: 'Debt Collector', |
| 134 | + className: 'Web21', |
| 135 | + grade: 100, |
| 136 | + favSubjects: ['Html', 'CSS', 'JavaScript'], |
| 137 | +}); |
| 138 | + |
| 139 | + const joscelyn = new Student({ |
| 140 | + name: "Joscelyn", |
| 141 | + age: 29, |
| 142 | + location: "California", |
| 143 | + previousBackground: "English teacher", |
| 144 | + className: 'Web21', |
| 145 | + grade: 91, |
| 146 | + favSubjects: ["Computer Science", "Philosophy", "English"], |
| 147 | +}); |
| 148 | + |
| 149 | + const marguel = new ProjectManager({ |
| 150 | + name: 'Marguel', |
| 151 | + age: 'Maybe 26', |
| 152 | + gradClassName: 'WEBPT2', |
| 153 | + favInstructor: 'Me?', |
| 154 | + location: 'California', |
| 155 | + specialty: 'React', |
| 156 | + favLanguage: 'JavaScript, Python, Elm etc.', |
| 157 | + catchPhrase: "Practice Flex Zombies !!!", |
| 158 | +}); |
| 159 | + |
| 160 | + const brandon = new ProjectManager({ |
| 161 | + name: 'Brandon', |
| 162 | + age: '34', |
| 163 | + gradClassName: 'WEB18', |
| 164 | + favInstructor: 'Professor Lambda', |
| 165 | + location: 'Maine', |
| 166 | + specialty: 'Redux', |
| 167 | + favLanguage: 'JavaScript, C++, Python.', |
| 168 | + catchPhrase: "You shall not pass!", |
| 169 | +}); |
| 170 | + |
| 171 | + const mary = new ProjectManager({ |
| 172 | + name: 'Mary', |
| 173 | + age: '24', |
| 174 | + gradClassName: 'WEB18', |
| 175 | + favInstructor: 'Josh Knell', |
| 176 | + location: 'New York', |
| 177 | + specialty: 'Express and Node.js', |
| 178 | + favLanguage: 'Javascript', |
| 179 | + catchPhrase: "That looks AWESOME", |
| 180 | +}); |
| 181 | + |
| 182 | + const christian = new ProjectManager({ |
| 183 | + name: 'Christian', |
| 184 | + age: '32', |
| 185 | + gradClassName: 'WEB18', |
| 186 | + favInstructor: 'Every Instructor in Lambda', |
| 187 | + location: 'Seattle, WA', |
| 188 | + specialty: 'Data Structures & Algorithms', |
| 189 | + favLanguage: 'JavaScript', |
| 190 | + catchPhrase: "Dont forget your daily commit.", |
| 191 | +}); |
| 192 | + |
| 193 | + const pat = new ProjectManager({ |
| 194 | + name: 'Pat', |
| 195 | + age: '38', |
| 196 | + gradClassName: 'WEB18', |
| 197 | + favInstructor: 'Brett Madrid', |
| 198 | + location: 'Petaluma, Ca', |
| 199 | + specialty: 'Empathetic to the struggle of Redux', |
| 200 | + favLanguage: 'JavaScript', |
| 201 | + catchPhrase: 'Lets google that together.' |
| 202 | +}); |
| 203 | + |
| 204 | + const darren = new ProjectManager({ |
| 205 | + name: 'Darren', |
| 206 | + age: '25', |
| 207 | + gradClassName: 'WEB18', |
| 208 | + favInstructor: 'Josh Knell', |
| 209 | + location: 'North Carolina', |
| 210 | + specialty: 'React', |
| 211 | + favLanguage: 'Javascript', |
| 212 | + catchPhrase: 'Gang. Gang.', |
| 213 | +}); |
| 214 | + |
| 215 | + const austin = new ProjectManager({ |
| 216 | + name: 'Austin', |
| 217 | + age: '23', |
| 218 | + gradClassName: 'WEB18', |
| 219 | + favInstructor: 'Josh Knell', |
| 220 | + location: 'Somewhere', |
| 221 | + specialty: 'Java', |
| 222 | + favLanguage: 'Java', |
| 223 | + catchPhrase: ":eggplant:", |
| 224 | +}); |
| 225 | + |
| 226 | + |
| 227 | +console.log(austin.name);// Austin |
| 228 | +console.log(matthew.location);// Toronto |
| 229 | +console.log(kevin.age);// 28 |
| 230 | +console.log(dan.speak());// Hello my name is Dan, I am from Denver |
| 231 | +console.log(joscelyn.listsSubjects())// Computer Science,Philosophy,English |
| 232 | +console.log(isaiah.sprintChallenge('prototypical inheritance'));// Isaiah has begun sprint challenge on prototypical inheritance |
| 233 | +console.log(pat.catchPhrase);//Lets google that together |
| 234 | +console.log(mary.debugsCode(joscelyn, 'CSS'));// Mary debugs Joscelyn's code on CSS |
| 235 | +console.log(dan.grade(joscelyn, 'JavaScript'));// Joscelyn receives a perfect score on JavaScript |
| 236 | +console.log(dan.giveActualGrade(joscelyn)); |
| 237 | +console.log(dan.mark(joscelyn)); |
| 238 | +console.log(dan.mark(joscelyn)); |
| 239 | +console.log(dan.mark(joscelyn)); |
| 240 | +console.log(dan.mark(joscelyn)); |
| 241 | +console.log(dan.mark(joscelyn)); |
| 242 | +console.log(dan.mark(joscelyn)); |
| 243 | +console.log(dan.mark(joscelyn)); |
| 244 | +console.log(dan.mark(joscelyn)); |
| 245 | +console.log(dan.mark(joscelyn)); |
| 246 | +console.log(dan.mark(joscelyn)); |
| 247 | +console.log(dan.mark(joscelyn)); |
| 248 | +console.log(dan.mark(joscelyn)); |
| 249 | +console.log(dan.mark(joscelyn)); |
| 250 | +console.log(joscelyn.graduate()); |
| 251 | + |
| 252 | + |
| 253 | + |
| 254 | + |
0 commit comments