Skip to content

Commit

Permalink
Apply three changes
Browse files Browse the repository at this point in the history
  • Loading branch information
felixp4 committed Sep 8, 2024
1 parent 8526391 commit be97b8b
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def validate(self, value: int) -> None:
raise TypeError("Expected value to be an int")

if value < self.min_amount or value > self.max_amount:
raise ValueError("Value error !!!")
raise ValueError(
f"Expected {value!r} to be no more than {self.min_amount}"
f"and less than {self.max_amount}."
)


class Visitor:
Expand Down Expand Up @@ -55,32 +58,19 @@ class Slide:
def __init__(
self,
name: str,
limitation_class: ChildrenSlideLimitationValidator
| AdultSlideLimitationValidator
limitation_class: type[SlideLimitationValidator]
) -> None:
self.name = name
self.limitation_class = limitation_class

def can_access(self, visitor: Visitor) -> None:
has_access = False
if visitor.age <= 60 and visitor.age >= 14:
if self.limitation_class is None:
self.limitation_class = AdultSlideLimitationValidator

if visitor.age <= 14 and visitor.age >= 4:
if self.limitation_class is None:
self.limitation_class = ChildrenSlideLimitationValidator

if self.limitation_class is not None:
try:
self.limitation_class(
visitor.age,
visitor.height,
visitor.weight
)
except ValueError:
has_access = False
else:
has_access = True

return has_access
try:
self.limitation_class(
visitor.age,
visitor.height,
visitor.weight
)
except ValueError:
return False
else:
return True

0 comments on commit be97b8b

Please sign in to comment.