adds chalet challenge
This commit is contained in:
parent
548c7bba7b
commit
d6a1cf4e40
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
|
@ -2100,7 +2100,46 @@ Take the additional class you made, such as vehicle and do some inheritance.
|
|||
For vehicles you could create a base class with a brand and number of wheels and seats.
|
||||
Then inherit for a bus, bike, car, cycle, etc.
|
||||
|
||||
## A *practical* example
|
||||
# Coding challenge - Chalet floor
|
||||
|
||||
Can you calculate me how much wood I need to order to build the base of my chalet?
|
||||
I have three different plans, you can see below.
|
||||
The idea behind this exercise is to create a `class` for each *base* shape.
|
||||
If you implement the *right* methods you can add, subtract, multiply your shapes as you wish.
|
||||
I created a library and imported it in my python shell so I can do the following.
|
||||
|
||||
```python
|
||||
>>> import shapes
|
||||
>>> sq1 = shapes.
|
||||
shapes.Circle( shapes.Rectangle( shapes.Shape( shapes.Square( shapes.Triangle( shapes.math
|
||||
>>> sq1 = shapes.Square(400)
|
||||
>>> cr1 = shapes.Circle(30)
|
||||
>>> re1 = shapes.Rectangle(400, 600)
|
||||
>>> total = sq1 + re1 - cr1
|
||||
>>> print(total)
|
||||
I'm a Shape with an area of 397172.57 cm2
|
||||
>>> print(re1)
|
||||
I'm a Rectangle with an area of 240000.00 cm2
|
||||
>>> print(cr1)
|
||||
I'm a Circle with an area of 2827.43 cm2
|
||||
>>> print(sq1)
|
||||
I'm a Square with an area of 160000.00 cm2
|
||||
>>>
|
||||
```
|
||||
|
||||
There are quite a few things in this exercise we have not seen in detail, so don't hesitate to research online and ask questions!
|
||||
This is a quite **advanced** challenge so you can be very proud of yourself if you understand the solution!
|
||||
|
||||
![first plan](./assets/plan_01_topview.png)
|
||||
|
||||
![second plan](./assets/plan_02_topview.png)
|
||||
|
||||
![third plan](./assets/plan_03_topview.png)
|
||||
|
||||
![third plan 3D view](./assets/plan_03_3d.png)
|
||||
|
||||
<details>
|
||||
<summary>Spoiler warning</summary>
|
||||
|
||||
```python
|
||||
import math
|
||||
|
@ -2167,6 +2206,8 @@ if __name__ == "__main__":
|
|||
print(combi)
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Now some *practical* improvements
|
||||
|
||||
### Improve the login generator
|
||||
|
|
Loading…
Reference in New Issue