Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Bondzik-S committed Oct 8, 2024
1 parent b165b7d commit b2adada
Showing 1 changed file with 72 additions and 1 deletion.
73 changes: 72 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,75 @@ 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:
self.name = name
self.weight = weight
self.coords = coords or [0, 0]

def go_forward(self, step: int = 1) -> list:
self.coords[1] += step
return self.coords

def go_back(self, step: int = 1) -> list:
self.coords[1] -= step
return self.coords

def go_right(self, step: int = 1) -> list:
self.coords[0] += step
return self.coords

def go_left(self, step: int = 1) -> list:
self.coords[0] -= step
return self.coords

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)
self.coords = coords or [0, 0, 0]

def go_up(self, step: int = 1) -> list:
self.coords[2] += step
return self.coords

def go_down(self, step: int = 1) -> list:
self.coords[2] -= step
return self.coords


class DeliveryDrone(FlyingRobot):
def __init__(
self,
name: str,
weight: int,
max_load_weight: int,
current_load: Cargo,
coords: list = None
) -> None:
super().__init__(name, weight, coords)
self.coords = coords or [0, 0, 0]
self.max_load_weight = max_load_weight
self.current_load = current_load

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

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

0 comments on commit b2adada

Please sign in to comment.