Skip to content

Commit 2762786

Browse files
Merge pull request #1 from Joscelyn1/joscelyn-owen
Joscelyn owen: stretch
2 parents 300f003 + 78133d9 commit 2762786

3 files changed

Lines changed: 463 additions & 29 deletions

File tree

README.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22

33
This challenge focuses on classes in JavaScript using the new `class` keyword.
44

5-
## Set Up The Project With Git
6-
7-
**Follow these steps to set up and work on your project:**
8-
9-
* [ ] Create a forked copy of this project.
10-
* [ ] Add your project manager as collaborator on Github.
11-
* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!).
12-
* [ ] Create a new branch: git checkout -b `<firstName-lastName>`.
13-
* [ ] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
14-
* [ ] Push commits: git push origin `<firstName-lastName>`.
15-
16-
**Follow these steps for completing your project.**
17-
18-
* [ ] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
19-
* [ ] Add your project manager as a reviewer on the pull-request
20-
* [ ] Your project manager will count the project as complete by merging the branch back into master.
215

226
## Assignment Description
237

@@ -110,10 +94,4 @@ const fred = new Instructor({
11094
* `standUp` a method that takes in a slack channel and logs `{name} announces to {channel}, @channel standy times!​​​​​
11195
* `debugsCode` a method that takes in a student object and a subject and logs out `{name} debugs {student.name}'s code on {subject}`
11296

113-
#### Stretch Problem
114-
115-
* Extend the functionality of the Student by adding a prop called grade and setting it equal to a number between 1-100.
116-
* Now that our students have a grade build out a method on the Instructor (this will be used by _BOTH_ instructors and PM's) that will randomly add or subtract points to a student's grade. _Math.random_ will help.
117-
* Add a graduate method to a student.
118-
* This method, when called, will check the grade of the student and see if they're ready to graduate from Lambda School
119-
* If the student's grade is above a 70% let them graduate! Otherwise go back to grading their assignments to increase their score.
97+
#### Stretch Problem

assignments/lambda-classes.js

Lines changed: 254 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,254 @@
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

Comments
 (0)