Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyShevchenkoDevil committed Oct 23, 2024
1 parent e832b24 commit 4820ec2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions app/cafe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from app.errors import (NotVaccinatedError,
OutdatedVaccineError,
NotWearingMaskError,
VaccineError)
NotWearingMaskError)
import datetime


Expand All @@ -18,7 +17,5 @@ def visit_cafe(self, visitor: dict) -> str:
elif not visitor["wearing_a_mask"]:
raise NotWearingMaskError("NotWearingMaskError")
return f"Welcome to {self.name}"
except VaccineError:
raise
except NotWearingMaskError:
raise
6 changes: 5 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

def go_to_cafe(friends: list, cafe: Cafe) -> str:
masks_to_buy = 0
not_vaccinated = 0
for friend in friends:
try:
cafe.visit_cafe(friend)
except VaccineError:
return "All friends should be vaccinated"
not_vaccinated += 1
except NotWearingMaskError:
masks_to_buy += 1

if not_vaccinated:
return "All friends should be vaccinated"

if masks_to_buy:
return f"Friends should buy {masks_to_buy} masks"
else:
Expand Down

0 comments on commit 4820ec2

Please sign in to comment.