Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6adb60a

Browse files
committed
Week9-homework-update
1 parent 70245f3 commit 6adb60a

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

JavaScript3/Week9/homework.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
Using classes help with structuring code. It is one of many **design patterns**. Second it **connects everything** you have learned in js: functions, properties, methods, keys, arrays.
55

66
## Lets make some art using classes
7-
In HTML5 there is an elements called canvas. It works just like a canvas. You can paint elements to the canvas.
7+
In HTML5 there is an elements called canvas. It works just like a canvas. You can paint elements like lines, circles and much more to the canvas.
88

99
### Paint a circle to a canvas element
10-
First add the canvas element to your html. Now draw a circle on the canvas using js. Google is your friend here :)
10+
First add the `canvas` element to your html. Now draw a circle on the `canvas` using js. Google is your friend here :)
1111

12-
When you have added a normal circle, try filling it out so it has a color.
12+
When you have added a normal circle, try filling it out so it has a color. Again google time!
1313

1414
### Class creation time!
1515
Lets create a class called `Circle`. The circle should be used like this:
@@ -20,14 +20,14 @@ c1.draw();
2020

2121
Where the constructor should look like this: `constructor(x, y, r, startAngle, endAngle, fillColor)`
2222

23-
The circle should have one method: `draw` that draws the circle to the canvas.
23+
The circle should have one method: `draw` that draws the circle to the canvas. That means that creating an instance of the circle class will not draw the circle. That first happens when we call the draw method.
2424

25-
Test if the new class works by creating a circle and drawing it to the canvas.
25+
Test if the new class works by creating a circle and drawing it to the canvas. Try some different radiuses and fill colors.
2626

2727
### Now lets make art!
2828
Every half second create a new circle class and draw that to the canvas.
2929

30-
The circle should have random `x`, `y`, `radius` and `color`.
30+
The circle should have random `x`, `y`, `radius` and `color`. For giving the `circle` a random color what should we do?? We should google off course!
3131

3232
What if we wanted the canvas to have the same width and height of the screen?
3333

@@ -36,17 +36,11 @@ Instead of the circles just randomly appearing on the screen, make them appear a
3636

3737

3838
## Getting into promises
39-
Get `movies` using this api: https://gist.githubusercontent.com/pankaj28843/08f397fcea7c760a99206bcb0ae8d0a4/raw/02d8bc9ec9a73e463b13c44df77a87255def5ab9/movies.json
39+
Lets use the github api to see what repositories different users have. You can use this url to get repositories for a specific github username, in this case the username `benna100`: `https://api.github.com/search/repositories?q=user:benna100`. Select 3 classmates github username that you want to show repositories for.
4040

41-
Show the movie poster and the title for the first 20 movies from the above api. To get a movie poster for a movie, use this api: https://developers.themoviedb.org/3/getting-started/introduction You need to investigate a bit how to get the poster for a given movie. But help each other in the class and ask questions if you struggle too much.
41+
Fetch all the 3 classmates repositories at the same time using Promise.all.
4242

43-
Think about `promise.all` and using chaining of `.then`.
44-
45-
Here is an example of how the output should be:
46-
47-
![Output example](assets/homework-movies.png)
48-
49-
hint: This task is difficult, so find someone to work with!
43+
When you have the data for the different repositories, render the fullname of the repo, url of the repo, and the owner of the repo. See [github-repos](homework/github-repos.html) as an example of how the renderered repos should look.
5044

5145
## Shopping cart using Classes
5246
Let's get a bit more into creating classes!
@@ -95,13 +89,15 @@ So we have two classes. `Product` represents products. `ShoppingCart` represents
9589
### Part 1
9690
Create the functionality for the `ShoppingCart` class.
9791
- `addProduct` should add a product to the products array.
98-
- `removeProduct` should remove a product from the products array.
99-
- `getTotal` should get the total price of the products.
92+
- `removeProduct` should remove a product from the products array. Hint look up indexOf
93+
- `getTotal` should get the total price of the products in the `shoppingcart`.
10094
- `renderProducts` should render the products to html. You decide what to show and how.
10195
- `getUser` should return a promise with the data from this api: https://jsonplaceholder.typicode.com/users/1
10296

10397
### Part 2
104-
Try and call the `addProduct` and the `removeProduct` functions. Call the `getUser` function to get a user. When the user has been fetched. Render the total price of the Shoppingcar, the username and the products in the shopping cart.
98+
Try and create some products and call the `addProduct` and the `removeProduct` functions to see if they work.
99+
100+
Call the `getUser` function to get a user. When the user has been fetched. Render the products using the `renderProducts` method. Also render the username and the total price of the products in the `shoppingcart`.
105101

106102
### Part 3
107103
The `Product` class function should get a method called `getPrice`. The function should have `currency` as a parameter. Depending on the currency return the correct price. Add 3 or more curriencies. Or use an api for getting the price dependent on a currency that getPrice uses.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<ul>
2+
<li>
3+
Benna100's repositories
4+
<ul>
5+
<li>
6+
easy-sourdough: https://github.com/benna100/easy-sourdough
7+
</li>
8+
<li>
9+
hyf-xmas: https://github.com/benna100/hyf-xmas
10+
</li>
11+
<li>
12+
53-milliarder: https://github.com/benna100/53-milliarder
13+
</li>
14+
</ul>
15+
</li>
16+
<li>
17+
testyMcTestface's repositories
18+
<ul>
19+
<li>
20+
test-tester: https://github.com/testyMcTestface/test-tester
21+
</li>
22+
<li>
23+
test-dont-like: https://github.com/testyMcTestface/test-dont-like
24+
</li>
25+
<li>
26+
test-repo-ONLY-for-testing: https://github.com/testyMcTestface/test-repo-ONLY-for-testing
27+
</li>
28+
</ul>
29+
</li>
30+
</ul>

0 commit comments

Comments
 (0)