Skip to content

Commit bb41122

Browse files
authored
Merge pull request #1 from sametweb/Samet-Mutevelli
Samet mutevelli
2 parents 300f003 + d434ac8 commit bb41122

File tree

5 files changed

+454
-82
lines changed

5 files changed

+454
-82
lines changed

README.md

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,114 +6,114 @@ This challenge focuses on classes in JavaScript using the new `class` keyword.
66

77
**Follow these steps to set up and work on your project:**
88

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>`.
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>`.
1515

1616
**Follow these steps for completing your project.**
1717

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.
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.
2121

2222
## Assignment Description
2323

2424
You already pretty much know all about classes but you're used to seeing them built in the following context:
2525

2626
```js
27-
function Person(personAttributes) {
27+
function Person(personAttributes) {
2828
this.name = personAttributes.name;
2929
this.age = personAttributes.age;
3030
this.location = personAttributes.location;
3131
}
3232

3333
const fred = new Person({
34-
name: 'Fred',
34+
name: "Fred",
3535
age: 37,
36-
location: 'Bedrock'
36+
location: "Bedrock"
3737
});
3838
```
3939

40-
* Because none of the above code is new, you're about to see your world get much much easier when dealing with Object Creation and Classical Inheritance as it pertains to JavaScript.
41-
* The Class Keyword makes this SO MUCH EASIER!
42-
* **Fork** and clone this repository.
43-
* **Complete** all of the exercises found in the assignment files.
40+
- Because none of the above code is new, you're about to see your world get much much easier when dealing with Object Creation and Classical Inheritance as it pertains to JavaScript.
41+
- The Class Keyword makes this SO MUCH EASIER!
42+
- **Fork** and clone this repository.
43+
- **Complete** all of the exercises found in the assignment files.
4444

4545
## `prototype-refactor` - Take existing code and make it modern.
4646

47-
* You're going to work with your prototypes assignment you built out yesterday.
48-
* `Challenge:` **Convert** all of your constructors into ES6 Classes using the `class` and `extends` keywords. You should be able to run your same logs and they should build out the proper expected behaviors.
47+
- You're going to work with your prototypes assignment you built out yesterday.
48+
- `Challenge:` **Convert** all of your constructors into ES6 Classes using the `class` and `extends` keywords. You should be able to run your same logs and they should build out the proper expected behaviors.
4949

5050
## `lambda-classes` - We need a roster of Lambda School personnel. Build it!
5151

52-
* We have a school to build here! This project will get you used to thinking about classes in JavaScript and building them from a brand new data set.
53-
* Lambda personnel can be broken down into three different types of `people`.
54-
* **Instructors** - extensions of Person
55-
* **Students** - extensions of Person
56-
* **Project Managers** - extensions of Instructors
57-
* **IMPORTANT** - You'll need to create 2 - 3 objects for each class and test them according to their unique Attributes. For example:
52+
- We have a school to build here! This project will get you used to thinking about classes in JavaScript and building them from a brand new data set.
53+
- Lambda personnel can be broken down into three different types of `people`.
54+
- **Instructors** - extensions of Person
55+
- **Students** - extensions of Person
56+
- **Project Managers** - extensions of Instructors
57+
- **IMPORTANT** - You'll need to create 2 - 3 objects for each class and test them according to their unique Attributes. For example:
5858

5959
```js
6060
const fred = new Instructor({
61-
name: 'Fred',
62-
location: 'Bedrock',
61+
name: "Fred",
62+
location: "Bedrock",
6363
age: 37,
64-
favLanguage: 'JavaScript',
65-
specialty: 'Front-end',
64+
favLanguage: "JavaScript",
65+
specialty: "Front-end",
6666
catchPhrase: `Don't forget the homies`
6767
});
6868
```
6969

7070
#### Person
7171

72-
* First we need a Person class. This will be our `base-class`
73-
* Person receives `name` `age` `location` all as props
74-
* Person receives `speak` as a method.
75-
* This method logs out a phrase `Hello my name is Fred, I am from Bedrock` where `name` and `location` are the object's own props
72+
- First we need a Person class. This will be our `base-class`
73+
- Person receives `name` `age` `location` all as props
74+
- Person receives `speak` as a method.
75+
- This method logs out a phrase `Hello my name is Fred, I am from Bedrock` where `name` and `location` are the object's own props
7676

7777
#### Instructor
7878

79-
* Now that we have a Person as our base class, we'll build our Instructor class.
80-
* Instructor uses the same attributes that have been set up by Person
81-
* Instructor has the following unique props:
82-
* `specialty` what the Instructor is good at i.e. 'redux'
83-
* `favLanguage` i.e. 'JavaScript, Python, Elm etc.'
84-
* `catchPhrase` i.e. `Don't forget the homies`
85-
* Instructor has the following methods:
86-
* `demo` receives a `subject` string as an argument and logs out the phrase 'Today we are learning about {subject}' where subject is the param passed in.
87-
* `grade` receives a `student` object and a `subject` string as arguments and logs out '{student.name} receives a perfect score on {subject}'
79+
- Now that we have a Person as our base class, we'll build our Instructor class.
80+
- Instructor uses the same attributes that have been set up by Person
81+
- Instructor has the following unique props:
82+
- `specialty` what the Instructor is good at i.e. 'redux'
83+
- `favLanguage` i.e. 'JavaScript, Python, Elm etc.'
84+
- `catchPhrase` i.e. `Don't forget the homies`
85+
- Instructor has the following methods:
86+
- `demo` receives a `subject` string as an argument and logs out the phrase 'Today we are learning about {subject}' where subject is the param passed in.
87+
- `grade` receives a `student` object and a `subject` string as arguments and logs out '{student.name} receives a perfect score on {subject}'
8888

8989
#### Student
9090

91-
* Now we need some students!
92-
* Student uses the same attributes that have been set up by Person
93-
* Student has the following unique props:
94-
* `previousBackground` i.e. what the Student used to do before Lambda School
95-
* `className` i.e. CS132
96-
* `favSubjects`. i.e. an array of the student's favorite subjects ['Html', 'CSS', 'JavaScript']
97-
* Student has the following methods:
98-
* `listsSubjects` a method that logs out all of the student's favoriteSubjects one by one.
99-
* `PRAssignment` a method that receives a subject as an argument and logs out that the `student.name has submitted a PR for {subject}`
100-
* `sprintChallenge` similar to PRAssignment but logs out `student.name has begun sprint challenge on {subject}`
91+
- Now we need some students!
92+
- Student uses the same attributes that have been set up by Person
93+
- Student has the following unique props:
94+
- `previousBackground` i.e. what the Student used to do before Lambda School
95+
- `className` i.e. CS132
96+
- `favSubjects`. i.e. an array of the student's favorite subjects ['Html', 'CSS', 'JavaScript']
97+
- Student has the following methods:
98+
- `listsSubjects` a method that logs out all of the student's favoriteSubjects one by one.
99+
- `PRAssignment` a method that receives a subject as an argument and logs out that the `student.name has submitted a PR for {subject}`
100+
- `sprintChallenge` similar to PRAssignment but logs out `student.name has begun sprint challenge on {subject}`
101101

102102
#### Project Manager
103103

104-
* Now that we have instructors and students, we'd be nowhere without our PM's
105-
* ProjectManagers are extensions of Instructors
106-
* ProjectManagers have the following unique props:
107-
* `gradClassName`: i.e. CS1
108-
* `favInstructor`: i.e. Sean
109-
* ProjectManagers have the following Methods:
110-
* `standUp` a method that takes in a slack channel and logs `{name} announces to {channel}, @channel standy times!​​​​​
111-
* `debugsCode` a method that takes in a student object and a subject and logs out `{name} debugs {student.name}'s code on {subject}`
104+
- Now that we have instructors and students, we'd be nowhere without our PM's
105+
- ProjectManagers are extensions of Instructors
106+
- ProjectManagers have the following unique props:
107+
- `gradClassName`: i.e. CS1
108+
- `favInstructor`: i.e. Sean
109+
- ProjectManagers have the following Methods:
110+
- `standUp` a method that takes in a slack channel and logs `{name} announces to {channel}, @channel standy times!​​​​​
111+
- `debugsCode` a method that takes in a student object and a subject and logs out `{name} debugs {student.name}'s code on {subject}`
112112

113113
#### Stretch Problem
114114

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.
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.

assignments/index.html

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22

33
<html lang="en">
4-
<head>
5-
<meta charset="utf-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="stylesheet" href="style.css" />
8+
<title>JS IV</title>
79

8-
<title>JS IV</title>
10+
<script src="prototype-refactor.js"></script>
11+
<script src="lambda-classes.js"></script>
12+
</head>
913

10-
<script src="prototype-refactor.js"></script>
11-
<script src="lambda-classes.js"></script>
12-
</head>
14+
<body>
15+
<h1>JS IV - Check your work in the console!</h1>
16+
<div class="healthBar">
17+
<h3>Press S to make Sniper hit Pudge</h3>
18+
<h3>Press P to make Pudge hit Sniper</h3>
1319

14-
<body>
15-
<h1>JS IV - Check your work in the console!</h1>
16-
</body>
17-
</html>
20+
<div class="sniper">
21+
<div id="SniperHealth">YOU WILL SEE HEALTH POINTS HERE!</div>
22+
</div>
23+
<div class="pudge"><div id="PudgeHealth"></div></div>
24+
<div id="over"></div>
25+
</div>
26+
</body>
27+
</html>

assignments/lambda-classes.js

Lines changed: 172 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,172 @@
1-
// CODE here for your Lambda Classes
1+
class Person {
2+
constructor(attrs) {
3+
this.name = attrs.name;
4+
this.age = attrs.age;
5+
this.location = attrs.location;
6+
}
7+
8+
speak() {
9+
console.log(`Hello, my name is ${this.name}, I am from ${this.location}`);
10+
}
11+
}
12+
13+
class Instructor extends Person {
14+
constructor(attrs) {
15+
super(attrs);
16+
this.speciality = attrs.speciality;
17+
this.favLanguage = attrs.favLanguage;
18+
this.catchPhrase = attrs.catchPhrase;
19+
}
20+
21+
demo(subject) {
22+
console.log(
23+
`Hello my name is ${this.name} and today we are learning about ${subject} where subject is the param passed in.`
24+
);
25+
}
26+
27+
grade(student, subject) {
28+
console.log(`${student.name} receives a perfect score on ${subject}`);
29+
}
30+
31+
changeGrade(student) {
32+
const randomPoint = Math.ceil((Math.random() * 100) / 5); // Random number between 0 to 20
33+
const randomOperation = Math.round(Math.random()) ? true : false;
34+
student.grade = randomOperation
35+
? student.grade + randomPoint // add if true
36+
: student.grade - randomPoint; // subtract if false
37+
const message = randomOperation
38+
? `${this.name} added ${randomPoint} points to ${student.name}'s grade. Final grade is ${student.grade}` // addition message
39+
: `${this.name} subtracted ${randomPoint} points from ${student.name}'s grade. Final grade is ${student.grade}`; // subtraction message
40+
console.log(message);
41+
}
42+
}
43+
44+
class Student extends Person {
45+
constructor(attrs) {
46+
super(attrs);
47+
this.previousBackground = attrs.previousBackground;
48+
this.className = attrs.className;
49+
this.favSubjects = attrs.favSubjects;
50+
this.grade = attrs.grade;
51+
}
52+
53+
listSubjects() {
54+
console.log(`${this.name}'s favorite topics are:`);
55+
return this.favSubjects.map((item, index) =>
56+
console.log(`${index + 1}.`, item)
57+
);
58+
}
59+
60+
PRAssignment(subject) {
61+
console.log(`${this.name} has submitted a PR for ${subject}.`);
62+
}
63+
64+
sprintChallenge(subject) {
65+
console.log(`${this.name} has begun sprint challenge on ${subject}`);
66+
}
67+
68+
graduate() {
69+
const gradMessage =
70+
this.grade < 70
71+
? `${this.name}'s grade is ${this.grade}, ergo not ready for graduation.`
72+
: `Congratulations, ${this.name}! Your grade ${this.grade} helps you graduate this year!`;
73+
console.log(gradMessage);
74+
}
75+
}
76+
77+
class TeamLead extends Instructor {
78+
constructor(attrs) {
79+
super(attrs);
80+
this.gradClassName = attrs.gradClassName;
81+
this.favInstructor = attrs.favInstructor;
82+
}
83+
84+
standUp(channel) {
85+
console.log(
86+
`${this.name} announces to ${channel}, @channel standy times!​​​​​`
87+
);
88+
}
89+
90+
debugsCode(student, subject) {
91+
console.log(`${this.name} debugs ${student.name}'s code on ${subject}`);
92+
}
93+
}
94+
95+
const pace = new Instructor({
96+
name: "Pace Ellsworth",
97+
age: "33",
98+
location: "Somewhere",
99+
speciality: "HTML, CSS, and JS",
100+
favLanguage: "CSS",
101+
catchPhrase: "Allright guys"
102+
});
103+
104+
const king = new Instructor({
105+
name: "David",
106+
age: "66",
107+
location: "His Kingdom",
108+
speciality: "C#",
109+
favLanguage: "Assembly",
110+
catchPhrase: "My reign begins"
111+
});
112+
113+
const jeffrey = new TeamLead({
114+
name: "Jeffrey Whitaker",
115+
age: "27",
116+
location: "Seattle",
117+
speciality: "Redux",
118+
favLanguage: "React",
119+
catchPhrase: "How is everybody doing",
120+
gradClassName: "WEB100",
121+
favInstructor: "Pace Ellsworth"
122+
});
123+
124+
const isla = new TeamLead({
125+
name: "Isla McNail",
126+
age: "23",
127+
location: "USA",
128+
speciality: "LESS",
129+
favLanguage: "Java",
130+
catchPhrase: "Hello everyone",
131+
gradClassName: "WEB101",
132+
favInstructor: "Pace Ellsworth"
133+
});
134+
135+
const samet = new Student({
136+
name: "Samet Mutevelli",
137+
age: "29",
138+
location: "Los Angeles",
139+
previousBackground: "Academia",
140+
className: "WEBPT11",
141+
favSubjects: ["Javascript", "React", "Redux"],
142+
grade: 70
143+
});
144+
145+
const zaza = new Student({
146+
name: "Batuhan Balta",
147+
age: "25",
148+
location: "Culver City",
149+
previousBackground: "Electrical Engineer",
150+
className: "WEBPT11",
151+
favSubjects: ["HTML", "CSS", "LESS", "Javascript"],
152+
grade: 75
153+
});
154+
155+
pace.demo("HTML");
156+
pace.grade(samet, "Javascript");
157+
king.demo("Java");
158+
king.grade(zaza, "LESS");
159+
160+
zaza.listSubjects();
161+
samet.listSubjects();
162+
zaza.PRAssignment("React");
163+
samet.PRAssignment("Javascript");
164+
zaza.sprintChallenge("HTML");
165+
samet.sprintChallenge("CSS");
166+
167+
jeffrey.standUp("#afterhours");
168+
isla.debugsCode(zaza, "Javascript");
169+
170+
pace.changeGrade(samet);
171+
172+
samet.graduate();

0 commit comments

Comments
 (0)