-
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 #1197
base: master
Are you sure you want to change the base?
Solution #1197
Changes from 1 commit
eef4f43
80b33e1
f625dcc
43cb183
e661cde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,72 @@ class Cargo: | |
def __init__(self, weight: int) -> None: | ||
self.weight = weight | ||
|
||
# write your code here | ||
|
||
class BaseRobot(Cargo): | ||
def __init__(self, | ||
name: str, | ||
weight: int, | ||
coords: list = None | ||
) -> None: | ||
super().__init__(weight) | ||
self.name = name | ||
if coords is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify to |
||
self.coords = [0, 0] | ||
else: | ||
self.coords = coords | ||
|
||
def go_forward(self, step: int = 1) -> None: | ||
self.coords[1] += step | ||
|
||
def go_back(self, step: int = 1) -> None: | ||
self.coords[1] -= step | ||
|
||
def go_right(self, step: int = 1) -> None: | ||
self.coords[0] += step | ||
|
||
def go_left(self, step: int = 1) -> None: | ||
self.coords[0] -= step | ||
|
||
def get_info(self) -> str: | ||
return f"Robot: {self.name}, Weight: {self.weight}" | ||
|
||
|
||
class FlyingRobot(BaseRobot): | ||
def __init__( | ||
self, | ||
name: str, | ||
weight: int, | ||
coords: list = None | ||
) -> None: | ||
super().__init__(name, weight, coords) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simplify to |
||
if coords is None: | ||
self.coords = [0, 0, 0] | ||
else: | ||
self.coords = coords | ||
|
||
def go_up(self, step: int = 1) -> None: | ||
self.coords[2] += step | ||
|
||
def go_down(self, step: int = 1) -> None: | ||
self.coords[2] -= step | ||
|
||
|
||
class DeliveryDrone(FlyingRobot): | ||
def __init__( | ||
self, | ||
name: str, | ||
weight: int, | ||
coords: list = None, | ||
max_load_weight: int = 0, | ||
current_load: int = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct annotation for current_load There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) -> 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.
place each argument including self on a new line