feat: Added favorite meal for each klient
This commit is contained in:
parent
42782fdcc0
commit
1f404aa166
@ -62,10 +62,16 @@ for person in root.findall('person'):
|
||||
age_element = person.find('age')
|
||||
age = int(age_element.text) if age_element is not None and age_element.text else 0
|
||||
|
||||
favorite_meal_element = person.find('favoriteMeal')
|
||||
favorite_meal = favorite_meal_element.text if favorite_meal_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)
|
||||
|
||||
person_data = {
|
||||
'imie': name,
|
||||
'nazwisko': surname,
|
||||
'wiek': age
|
||||
'wiek': age,
|
||||
'ulubiony_posilek': favorite_meal
|
||||
}
|
||||
|
||||
clients.append(Klient(**person_data))
|
||||
|
@ -3,12 +3,13 @@ from rachunek import Rachunek
|
||||
import random
|
||||
|
||||
class Klient:
|
||||
def __init__(self,imie,nazwisko,wiek):
|
||||
def __init__(self,imie,nazwisko,wiek,ulubiony_posilek=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
|
||||
|
||||
def zloz_zamowienie(self,zamowienie,stolik):
|
||||
if self.stolik is None:
|
||||
@ -20,4 +21,5 @@ class Klient:
|
||||
print("Klient ma juz przypisany stolik.")
|
||||
|
||||
def __str__(self):
|
||||
return f"Klient: {self.imie} {self.nazwisko} {self.wiek}"
|
||||
return f"Klient: {self.imie} {self.nazwisko} {self.wiek}, ulubione Danie: {self.ulubiony_posilek}"
|
||||
|
||||
|
@ -3,20 +3,24 @@
|
||||
<name>David</name>
|
||||
<surname>Bowie</surname>
|
||||
<age>21</age>
|
||||
<favoriteMeal>Tatar</favoriteMeal>
|
||||
</person>
|
||||
<person>
|
||||
<name>Kamil</name>
|
||||
<surname>Stop</surname>
|
||||
<age>17</age>
|
||||
<favoriteMeal>Pomidorowa z Makaronem</favoriteMeal>
|
||||
</person>
|
||||
<person>
|
||||
<name>Jon</name>
|
||||
<surname>Snow</surname>
|
||||
<age>23</age>
|
||||
<favoriteMeal>Grochówka</favoriteMeal>
|
||||
</person>
|
||||
<person>
|
||||
<name>Andrzej</name>
|
||||
<surname>Kowalski</surname>
|
||||
<age>44</age>
|
||||
<favoriteMeal>Spaghetti Bolognese</favoriteMeal>
|
||||
</person>
|
||||
</people>
|
||||
</people>
|
||||
|
Loading…
Reference in New Issue
Block a user