-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #1240
base: master
Are you sure you want to change the base?
solution #1240
Conversation
app/main.py
Outdated
if coords is None: | ||
coords = [0, 0, 0] | ||
elif len(coords) == 2: | ||
coords.append(0) | ||
elif len(coords) == 3: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GJ!
But could you write it shorter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+, fix it here too
app/main.py
Outdated
def __init__(self, name: str, weight: int, coords: list = None) -> None: | ||
self.name = name | ||
self.weight = weight | ||
self.coords = coords if coords is not None else [0, 0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor it using or
app/main.py
Outdated
# write your code here | ||
|
||
class BaseRobot: | ||
def __init__(self, name: str, weight: int, coords: list = None) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add more descriptive annotation for coords
. Check other annotation too
app/main.py
Outdated
if coords is None: | ||
coords = [0, 0, 0] | ||
elif len(coords) == 2: | ||
coords.append(0) | ||
elif len(coords) == 3: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+, fix it here too
app/main.py
Outdated
def __init__(self, name: str, | ||
weight: int, coords: list = None, | ||
max_load_weight: int = 0, | ||
current_load: Cargo = None) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start every argument from a new line(start name
from a new line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
coords: Optional[List[int]] = None) -> None: | ||
if coords is None: | ||
coords = [0, 0, 0] | ||
elif len(coords) == 2: | ||
coords.append(0) | ||
super().__init__(name, weight, coords[:2]) | ||
self.coords = coords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling coords parameter in the FlyingRobot class: You're adjusting coords to handle 2D or 3D coordinates, but the way you pass them to BaseRobot isn't consistent.
class DeliveryDrone(FlyingRobot): | ||
def __init__(self, | ||
name: str, | ||
weight: int, | ||
coords: Optional[List[int]] = None, | ||
max_load_weight: int = 0, | ||
current_load: Cargo = None) -> None: | ||
super().__init__(name, weight, coords) | ||
self.max_load_weight = max_load_weight | ||
self.current_load = current_load | ||
|
||
def hook_load(self, cargo: Cargo) -> None: | ||
if self.current_load is None and cargo.weight <= self.max_load_weight: | ||
self.current_load = cargo | ||
|
||
def unhook_load(self) -> None: | ||
self.current_load = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling the max_load_weight and current_load in DeliveryDrone: The current_load is a Cargo object but the default value should be None. Also, Cargo is passed correctly, but handling load conditions can be a bit more explicit.
No description provided.