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_element = person.find('age')
|
||||||
age = int(age_element.text) if age_element is not None and age_element.text else 0
|
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 = {
|
person_data = {
|
||||||
'imie': name,
|
'imie': name,
|
||||||
'nazwisko': surname,
|
'nazwisko': surname,
|
||||||
'wiek': age
|
'wiek': age,
|
||||||
|
'ulubiony_posilek': favorite_meal
|
||||||
}
|
}
|
||||||
|
|
||||||
clients.append(Klient(**person_data))
|
clients.append(Klient(**person_data))
|
||||||
|
@ -3,12 +3,13 @@ from rachunek import Rachunek
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
class Klient:
|
class Klient:
|
||||||
def __init__(self,imie,nazwisko,wiek):
|
def __init__(self,imie,nazwisko,wiek,ulubiony_posilek=None):
|
||||||
self.imie = imie
|
self.imie = imie
|
||||||
self.nazwisko = nazwisko
|
self.nazwisko = nazwisko
|
||||||
self.wiek = wiek
|
self.wiek = wiek
|
||||||
self.stolik = None
|
self.stolik = None
|
||||||
self.rachunek = Rachunek(random.randint(1,1000))
|
self.rachunek = Rachunek(random.randint(1,1000))
|
||||||
|
self.ulubiony_posilek = ulubiony_posilek
|
||||||
|
|
||||||
def zloz_zamowienie(self,zamowienie,stolik):
|
def zloz_zamowienie(self,zamowienie,stolik):
|
||||||
if self.stolik is None:
|
if self.stolik is None:
|
||||||
@ -20,4 +21,5 @@ class Klient:
|
|||||||
print("Klient ma juz przypisany stolik.")
|
print("Klient ma juz przypisany stolik.")
|
||||||
|
|
||||||
def __str__(self):
|
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>
|
<name>David</name>
|
||||||
<surname>Bowie</surname>
|
<surname>Bowie</surname>
|
||||||
<age>21</age>
|
<age>21</age>
|
||||||
|
<favoriteMeal>Tatar</favoriteMeal>
|
||||||
</person>
|
</person>
|
||||||
<person>
|
<person>
|
||||||
<name>Kamil</name>
|
<name>Kamil</name>
|
||||||
<surname>Stop</surname>
|
<surname>Stop</surname>
|
||||||
<age>17</age>
|
<age>17</age>
|
||||||
|
<favoriteMeal>Pomidorowa z Makaronem</favoriteMeal>
|
||||||
</person>
|
</person>
|
||||||
<person>
|
<person>
|
||||||
<name>Jon</name>
|
<name>Jon</name>
|
||||||
<surname>Snow</surname>
|
<surname>Snow</surname>
|
||||||
<age>23</age>
|
<age>23</age>
|
||||||
|
<favoriteMeal>Grochówka</favoriteMeal>
|
||||||
</person>
|
</person>
|
||||||
<person>
|
<person>
|
||||||
<name>Andrzej</name>
|
<name>Andrzej</name>
|
||||||
<surname>Kowalski</surname>
|
<surname>Kowalski</surname>
|
||||||
<age>44</age>
|
<age>44</age>
|
||||||
|
<favoriteMeal>Spaghetti Bolognese</favoriteMeal>
|
||||||
</person>
|
</person>
|
||||||
</people>
|
</people>
|
||||||
|
Loading…
Reference in New Issue
Block a user