Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Recept():
- def __init__(self, ime = '', autor = '', brojsastojaka = 0):
- self.imeRecepta = ime
- self.autorRecepta = autor
- self.brojsastojaka = brojsastojaka
- self.Sastojak = [{'Ime': '', 'Kolicina':'' }]
- self.sastojci(self.brojsastojaka)
- self.x = self.tezina_pripreme()
- def sastojci(self, brojsastojaka):
- for i in range(0, self.brojsastojaka):
- self.imeSastojka = input('Unesi ime sastojka ')
- self.kolicinaSastojka = input('Unesi kolicinu sastojka ')
- self.Sastojak.append({'Ime':self.imeSastojka, 'Kolicina':self.kolicinaSastojka})
- def ispisi_sastojke(self):
- self.Sastojak.append({'Ime' : 'Dobro raspolozenje', 'Kolicina' : 'Sto veca'})
- for a in range(0,self.brojsastojaka+1):
- print(self.Sastojak[a+1]['Ime'], ' : ', self.Sastojak[a+1]['Kolicina'])
- def tezina_pripreme(self):
- while(True):
- self.ocjena = int(input('Unesi tezinu pripreme 1-3 '))
- if(self.ocjena>0 and self.ocjena<4):
- return self.ocjena
- break
- else:
- print("Pogresan unos")
- continue
- def ispis_recepta(self, brojrecepta):
- self.brojrecepta = brojrecepta
- print('---------------------------------------')
- print('Recept br:', self.brojrecepta+1, '->', ime)
- print('Autor recepta:', self.autorRecepta)
- print('Tezina pripreme:', self.x)
- self.ispisi_sastojke()
- print('---------------------------------------')
- brojacrecepata = 0
- lista_recepata = []
- while(True):
- ime = input('Unesi ime recepta ')
- autor = input('Unesi ime autora ')
- brojsastojaka = int(input('Unesi broj sastojaka '))
- lista_recepata.append(Recept(ime, autor, brojsastojaka))
- ###lista_recepata[brojacrecepata].sastojci(brojsastojaka)
- lista_recepata[brojacrecepata].ispis_recepta(brojacrecepata)
- odgovor = input('Da li zelite unijeti sljedeci recept ')
- if(odgovor == 'da' or odgovor == 'dA' or odgovor == 'Da' or odgovor == 'DA'):
- brojacrecepata+=1
- continue
- else:
- break
- input()
- c = 0
- for a in lista_recepata:
- a.ispis_recepta(c)
- c = c+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement