Advertisement
Walker1998

Untitled

May 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.32 KB | None | 0 0
  1. f = open("test.txt","w")
  2. class Recept():
  3.     def __init__(self, ime = '', autor = '', brojsastojaka = 0):
  4.         self.imeRecepta = ime
  5.         self.autorRecepta = autor
  6.         self.Sastojak = [ {'Ime':'' , 'Kolicina':'' } ]
  7.         self.brojsastojaka = brojsastojaka
  8.     def ispisipodatke(self):
  9.         print(self.imeRecepta)
  10.         print(self.autorRecepta)
  11.     def sastojci(self, brojsastojaka):
  12.         for i in range(0, self.brojsastojaka):
  13.             self.imeSastojka = input('Unesi ime sastojka ')
  14.             self.kolicinaSastojka = input('Unesi kolicinu sastojka ')
  15.             self.Sastojak.append({'Ime':self.imeSastojka, 'Kolicina':self.kolicinaSastojka})
  16.     def ispisi_sastojke(self):
  17.         self.Sastojak.append({'Ime' : 'Dobro raspolozenje', 'Kolicina' : 'Sto veca'})
  18.         for a in range(0,self.brojsastojaka+1):
  19.             print(self.Sastojak[a+1]['Ime'], ' : ', self.Sastojak[a+1]['Kolicina'], file = f)
  20.     def tezina_pripreme(self):
  21.         while(True):
  22.             self.ocjena = int(input('Unesi tezinu pripreme 1-3 '))
  23.             if(self.ocjena>0 and self.ocjena<4):
  24.                 return self.ocjena
  25.                 break
  26.             else:
  27.                 print("Pogresan unos")
  28.                 continue
  29.     def ispis_recepta(self, brojrecepta):
  30.         print('---------------------------------------', file = f)
  31.         print('Recept br:', brojacrecepata+1, '->', ime, file = f)
  32.         print('Autor recepta:', autor, file = f)
  33.         print('Tezina pripreme:', tezinapripreme, file = f)
  34.         self.ispisi_sastojke()
  35.         print('---------------------------------------', file = f)
  36.        
  37. brojacrecepata = 0
  38. lista_recepata = []
  39. while(True):
  40.     ime = input('Unesi ime recepta ')
  41.     autor = input('Unesi ime autora ')
  42.     brojsastojaka = int(input('Unesi broj sastojaka '))                
  43.     lista_recepata.append(Recept(ime, autor, brojsastojaka))
  44.     lista_recepata[brojacrecepata].sastojci(brojsastojaka)
  45.     tezinapripreme = lista_recepata[brojacrecepata].tezina_pripreme()
  46.     (lista_recepata[brojacrecepata].ispis_recepta(brojacrecepata))
  47.     odgovor = input('Da li zelite unijeti sljedeci recept ')
  48.     if(odgovor == 'da' or odgovor == 'dA' or odgovor == 'Da' or odgovor == 'DA'):
  49.         brojacrecepata+=1
  50.         continue
  51.     else:  
  52.         break
  53.    
  54.        
  55. input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement