Skip to content

Commit

Permalink
clarify task description
Browse files Browse the repository at this point in the history
  • Loading branch information
LLkaia committed Oct 25, 2024
1 parent b165b7d commit e8301f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ Let's implement 3 classes with inheritance
- the `__init__` method takes `name`, `weight`, `coords`,
and saves them
- `coords` is list with `x` and `y` coordinates, set to [0, 0] by default.
It is not a good practice to use mutable object as a default parameter,
set it to `None` by default, and use condition.
It is not a good practice to use mutable object as a default parameter of function,
set it to `None` by default. But in constructor itself you can use condition, and if `coords` equal to None,
assign [0, 0] to the `coords`.
- `go_forward`, `go_back`, `go_right` and `go_left` methods
take a `step` argument (1 by default) and move the robot by
`step` in the appropriate direction.
Positive Y axis is forward, positive X axis is right.
These functions should not return anything.
- `get_info` method returns a string in the next format `Robot: {name}, Weight: {weight}`
```python
robot = BaseRobot(name="Walle", weight=34, coords=[3, -2])
Expand Down Expand Up @@ -45,10 +47,14 @@ flying_robot.go_up(10)
- takes the same args as `FlyingRobot` and passes them
to the parent's `__init__` method.
- the `__init__` method also takes and stores `max_load_weight` and `current_load`.
`max_load_weight` purpose is to store robot's load capacity.
`current_load` purpose is to store `Cargo` instance, and it can be None by default.
If `Cargo` object was passed to function, use method `hook_load` to check if it can be hooked.
- has `hook_load` method taking `Cargo` object and saves it to
`current_load` if `current_load` is `None` and `cargo.weight` not greater than
`max_load_weight` of the drone
- has `unhook_load` method, that set `current_load` to None
`current_load` if two conditions are True: `current_load` is set
to `None` and `cargo.weight` not greater than`max_load_weight`
of the drone, otherwise, do nothing.
- has `unhook_load` method, that set `current_load` to None without any additional logic.
```python
cargo = Cargo(14)
drone = DeliveryDrone(
Expand Down Expand Up @@ -76,3 +82,5 @@ drone = DeliveryDrone(
drone.unhook_load()
# drone.current_load is None
```

### Note: Check your code using this [checklist](checklist.md) before pushing your solution.
16 changes: 16 additions & 0 deletions checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Check Your Code Against the Following Points

1. If the function definition line is too long, place each parameter on a new line.
```
def long_function_name(
var_one,
var_two,
var_three,
var_four
) -> None:
```
2. If a variable can be `None`, you need to specify it in the annotation.
3. Make sure you're not repeating yourself. If something can be done in the parent class, delegate it there.
4. Remember, if you want to check if a variable is set to `None` and assign a default value to it,
you can use the ternary operator: `variable = other if other else 0`.
Or even simpler: `variable = other or 0`. Simple is better than complex.

0 comments on commit e8301f9

Please sign in to comment.