Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open("test.txt","w")
- class Recept():
- def __init__(self, ime = '', autor = '', brojsastojaka = 0):
- self.imeRecepta = ime
- self.autorRecepta = autor
- self.Sastojak = [ {'Ime':'' , 'Kolicina':'' } ]
- self.brojsastojaka = brojsastojaka
- def ispisipodatke(self):
- print(self.imeRecepta)
- print(self.autorRecepta)
- 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'], file = f)
- 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):
- print('---------------------------------------', file = f)
- print('Recept br:', brojacrecepata+1, '->', ime, file = f)
- print('Autor recepta:', autor, file = f)
- print('Tezina pripreme:', tezinapripreme, file = f)
- self.ispisi_sastojke()
- print('---------------------------------------', file = f)
- 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)
- tezinapripreme = lista_recepata[brojacrecepata].tezina_pripreme()
- (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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement