Skip to content

Commit

Permalink
task completed (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniilHinzburh committed Sep 18, 2023
1 parent 1eb7d1a commit 61e2a9a
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,63 @@


class IntegerRange:
pass
def __init__(self, min_amount: int, max_amount: int) -> None:
self.name = None
self.min_amount = min_amount
self.max_amount = max_amount

def __get__(self, instance: object, owner: object) -> int:
return instance.__dict__[self.name]

def __set__(self, instance: object, value: int) -> None:
instance.__dict__[self.name] = value

def __set_name__(self, owner: object, name: str) -> None:
self.name = name


class Visitor:
pass
def __init__(self, name: str, age: int, weight: int, height: int) -> None:
self.name = name
self.age = age
self.weight = weight
self.height = height


class SlideLimitationValidator(ABC):
pass
def __init__(self, age: int, weight: int, height: int) -> None:
self.age = age
self.weight = weight
self.height = height

def validate(self, visitor: Visitor) -> bool:
if (self.age.min_amount <= visitor.age <= self.age.max_amount
and (self.weight.min_amount <= visitor.weight <= (
self.weight.max_amount))
and (self.height.min_amount <= visitor.height <= (
self.height.max_amount))):
return True
return False


class ChildrenSlideLimitationValidator(SlideLimitationValidator):
pass
def __init__(self) -> None:
super().__init__(age=IntegerRange(4, 14),
weight=IntegerRange(20, 50),
height=IntegerRange(80, 120))


class AdultSlideLimitationValidator(SlideLimitationValidator):
pass
def __init__(self) -> None:
super().__init__(age=IntegerRange(14, 60),
weight=IntegerRange(50, 120),
height=IntegerRange(120, 220))


class Slide:
pass
def __init__(self, name: str, limitation_class: object) -> None:
self.name = name
self.limitation_class = limitation_class()

def can_access(self, visitor: Visitor) -> bool:
return self.limitation_class.validate(visitor)

0 comments on commit 61e2a9a

Please sign in to comment.