Skip to content
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

Develop #1213

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Develop #1213

Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,63 @@ class Cargo:
def __init__(self, weight: int) -> None:
self.weight = weight

# write your code here

class BaseRobot:
def __init__(self, name: str, weight: int, coords: list = None) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, name: str, weight: int, coords: list = None) -> None:
def __init__(self, name: str, weight: int, coords: list[int] = None) -> None:

self.name = name
self.weight = weight
if coords:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if coords:
self.coords = coords or [0, 0]

self.coords = coords
else:
self.coords = [0, 0]

def get_info(self) -> str:
return f"Robot: {self.name}, Weight: {self.weight}"

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


class FlyingRobot(BaseRobot):
def __init__(self, name: str, weight: int, coords: list = None) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, name: str, weight: int, coords: list = None) -> None:
def __init__(self, name: str, weight: int, coords: list[int] = None) -> None:

super().__init__(name, weight, coords)
if coords:
self.coords = coords
else:
self.coords = [0, 0, 0]

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,
) -> None:
super().__init__(name, weight, coords)
self.max_load_weight = max_load_weight
self.current_load = current_load

def hook_load(self, load: Cargo) -> None:
if not self.current_load and load.weight <= self.max_load_weight:
self.current_load = load

def unhook_load(self) -> None:
self.current_load = None
Loading