Skip to content

Commit

Permalink
'deleted_repeating_code'
Browse files Browse the repository at this point in the history
  • Loading branch information
ABaidin committed Aug 24, 2024
1 parent c163f61 commit fab356c
Showing 1 changed file with 9 additions and 32 deletions.
41 changes: 9 additions & 32 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from abc import ABC


class IntegerRange:
Expand Down Expand Up @@ -41,18 +41,6 @@ def __init__(
self.weight_range = weight
self.height_range = height

@abstractmethod
def validate(self, visitor: Visitor) -> bool:
pass


class ChildrenSlideLimitationValidator(SlideLimitationValidator):
def __init__(self) -> None:
age_range = IntegerRange(4, 14)
weight_range = IntegerRange(20, 50)
height_range = IntegerRange(80, 120)
super().__init__(age_range, weight_range, height_range)

def validate(self, visitor: Visitor) -> bool:
return (
(
Expand All @@ -73,32 +61,21 @@ def validate(self, visitor: Visitor) -> bool:
)


class ChildrenSlideLimitationValidator(SlideLimitationValidator):
def __init__(self) -> None:
age_range = IntegerRange(4, 14)
weight_range = IntegerRange(20, 50)
height_range = IntegerRange(80, 120)
super().__init__(age_range, weight_range, height_range)


class AdultSlideLimitationValidator(SlideLimitationValidator):
def __init__(self) -> None:
age_range = IntegerRange(14, 60)
weight_range = IntegerRange(50, 120)
height_range = IntegerRange(120, 220)
super().__init__(age_range, weight_range, height_range)

def validate(self, visitor: Visitor) -> bool:
return (
(
self.age_range.min_amount
<= visitor.age
<= self.age_range.max_amount
)
and (
self.weight_range.min_amount
<= visitor.weight
<= self.weight_range.max_amount
)
and (
self.height_range.min_amount
<= visitor.height
<= self.height_range.max_amount
)
)


class Slide:
def __init__(
Expand Down

0 comments on commit fab356c

Please sign in to comment.