feat: Added logic_processor with example statement, and diet restriction for Clients
This commit is contained in:
parent
1f404aa166
commit
c2b3944373
@ -64,6 +64,10 @@ for person in root.findall('person'):
|
||||
|
||||
favorite_meal_element = person.find('favoriteMeal')
|
||||
favorite_meal = favorite_meal_element.text if favorite_meal_element is not None else None
|
||||
|
||||
restriction_element = person.find('restrictions')
|
||||
restrictions = restriction_element.text if restriction_element is not None else None
|
||||
|
||||
if favorite_meal in [meal.nazwa for meal in meals]:
|
||||
favorite_meal = next((meal for meal in meals if meal.nazwa == favorite_meal), None)
|
||||
|
||||
@ -71,7 +75,8 @@ for person in root.findall('person'):
|
||||
'imie': name,
|
||||
'nazwisko': surname,
|
||||
'wiek': age,
|
||||
'ulubiony_posilek': favorite_meal
|
||||
'ulubiony_posilek': favorite_meal,
|
||||
'restrykcje_dietowe': restrictions
|
||||
}
|
||||
|
||||
clients.append(Klient(**person_data))
|
||||
@ -135,10 +140,13 @@ for klient in [k for k in clients if k.stolik is not None]:
|
||||
print(f"Klient {klient.imie} {klient.nazwisko} ma następujące Zamowienia:")
|
||||
print(f"\t{klient.rachunek} i sumą {klient.rachunek.suma()}")
|
||||
|
||||
print("----------------\n\n")
|
||||
|
||||
import logic_test as logic
|
||||
|
||||
|
||||
|
||||
for klient in [k for k in clients if k.stolik is not None]:
|
||||
for zamownienie in klient.rachunek.zamowienia:
|
||||
print(logic.diet_restriction(zamowienie, klient))
|
||||
# for meal in meals:
|
||||
# print(meal)
|
||||
|
||||
|
@ -3,14 +3,14 @@ from rachunek import Rachunek
|
||||
import random
|
||||
|
||||
class Klient:
|
||||
def __init__(self,imie,nazwisko,wiek,ulubiony_posilek=None):
|
||||
def __init__(self,imie,nazwisko,wiek,ulubiony_posilek=None, restrykcje_dietowe=None):
|
||||
self.imie = imie
|
||||
self.nazwisko = nazwisko
|
||||
self.wiek = wiek
|
||||
self.stolik = None
|
||||
self.rachunek = Rachunek(random.randint(1,1000))
|
||||
self.ulubiony_posilek = ulubiony_posilek
|
||||
|
||||
self.restrykcje_dietowe = restrykcje_dietowe
|
||||
def zloz_zamowienie(self,zamowienie,stolik):
|
||||
if self.stolik is None:
|
||||
self.stolik = stolik
|
||||
@ -21,5 +21,5 @@ class Klient:
|
||||
print("Klient ma juz przypisany stolik.")
|
||||
|
||||
def __str__(self):
|
||||
return f"Klient: {self.imie} {self.nazwisko} {self.wiek}, ulubione Danie: {self.ulubiony_posilek}"
|
||||
return f"Klient: {self.imie} {self.nazwisko} {self.wiek}, ulubione Danie: {self.ulubiony_posilek}, restrykcje diet: {self.restrykcje_dietowe}"
|
||||
|
||||
|
14
classes/data/logic_test.py
Normal file
14
classes/data/logic_test.py
Normal file
@ -0,0 +1,14 @@
|
||||
def diet_restriction(meals,client):
|
||||
for meal in meals:
|
||||
vegan,vegetarian,meat = meal.vegan_vegetarian_meat
|
||||
print(meal)
|
||||
print(client.restrykcje_dietowe)
|
||||
if vegan and client.restrykcje_dietowe == 'Vegan':
|
||||
return True
|
||||
elif vegetarian and (client.restrykcje_dietowe == 'Vegetarian' or meat and client.restrykcje_dietowe == 'Vegan'):
|
||||
return True
|
||||
elif client.restrykcje_dietowe == 'Meat':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -5,7 +5,6 @@ from posilek import Posilek
|
||||
class Zamowienie:
|
||||
def __init__(self,numer_zamowienia,posilek):
|
||||
self.numer_zamowienia = numer_zamowienia
|
||||
print(type(posilek))
|
||||
assert all(isinstance(p, Posilek) for p in posilek), "Zamowienie: posilek nie jest listą tylko typu Posilek"
|
||||
self.posilek = posilek
|
||||
def __str__(self):
|
||||
|
@ -4,23 +4,28 @@
|
||||
<surname>Bowie</surname>
|
||||
<age>21</age>
|
||||
<favoriteMeal>Tatar</favoriteMeal>
|
||||
<restrictions>Meat</restrictions>
|
||||
</person>
|
||||
<person>
|
||||
<name>Kamil</name>
|
||||
<surname>Stop</surname>
|
||||
<age>17</age>
|
||||
<favoriteMeal>Pomidorowa z Makaronem</favoriteMeal>
|
||||
<restrictions>Vegetarian</restrictions>
|
||||
</person>
|
||||
<person>
|
||||
<name>Jon</name>
|
||||
<surname>Snow</surname>
|
||||
<age>23</age>
|
||||
<favoriteMeal>Grochówka</favoriteMeal>
|
||||
<restrictions>Vegan</restrictions>
|
||||
|
||||
</person>
|
||||
<person>
|
||||
<name>Andrzej</name>
|
||||
<surname>Kowalski</surname>
|
||||
<age>44</age>
|
||||
<favoriteMeal>Spaghetti Bolognese</favoriteMeal>
|
||||
<restrictions>Meat</restrictions>
|
||||
</person>
|
||||
</people>
|
||||
|
@ -66,7 +66,7 @@
|
||||
</alergens>
|
||||
<vegetarian>false</vegetarian>
|
||||
<vegan>true</vegan>
|
||||
<meat>true</meat>
|
||||
<meat>false</meat>
|
||||
</meal> <meal>
|
||||
<name>Pomidorowa z Makaronem</name>
|
||||
<type>Soup</type>
|
||||
|
Loading…
Reference in New Issue
Block a user