def sv_undo(s,us): if lenght(us)==0: return "Can't undo no more" elif lenght(us)==1: del s[:] return s else: us.pop(len(us)-1) s2=create_state() s2+=us[lenght(us)-1] del s[:] s=s2.copy() return s
def sv_del_tz_tip(s,T): ''' Functie ce sterge tranzactiile de un anumit tip input : s - lista tranzactiilor, T - un tip output : lista dupa stergeri ''' if lenght(s)==0: return 'Lista este goala!' i=0 while i<lenght(s): if get_tip(s[i])==T: s.pop(i) else: i+=1 return s
def sv_del_tz_zi(s,Z): ''' Functie ce sterge tranzactiile dintr-o anumita zi input : s - lista tranzactiilor, Z - o zi output : s - lista dupa stergeri ''' if lenght(s)==0: return 'Lista este goala!' i=0 while i<lenght(s): if get_zi(s[i])==Z: s.pop(i) else: i+=1 return s
def new_UI_print(s,us,x): if lenght(s)==0: print("Nu exista tranzactii!") else: print("Lista este: ") for tz in s: print("zi:",tz['zi'],", suma:",tz['suma'],", tipul:",tz['tip'])
def new_UI_undo(s,us,x): if lenght(s)==0: print("Can't undo!") else: del s[:] s+=sv_undo(s,us).copy() print("Undo efectuat cu succes!")
def sv_del_tz_per(s,Z1,Z2): ''' Functie ce sterge tranzactiile dintr-o anumita perioada input : s - lista tranzactiilor, Z1,Z2 - doua zile output : s - lista dupa stergeri ''' if lenght(s)==0: return 'Lista este goala!' i=0 if Z1>Z2: Z1,Z2=Z2,Z1 while i<lenght(s): if get_zi(s[i])>=Z1 and get_zi(s[i])<=Z2: s.pop(i) else: i+=1 return s
def sv_tz_tip_ord(T,s): ''' Functie ce tipareste toate tranzactiile de un anumit tip, ordonate dupa suma input : T - un tip, s - lista tranzactiilor output : s3 - lista tranzactiilor de un anumit tip ''' if lenght(s)==0: return 'Lista este goala!' s2=s.copy() for i in range(0,lenght(s2)-1,1): for j in range(i+1,lenght(s2),1): if get_suma(s2[i])>get_suma(s2[j]): s2[i],s2[j]=s2[j],s2[i] s3=create_state() for tz in s2: if get_tip(tz)==T: add_tz(s3, tz) return s3
def sv_sum_tip(T,s): ''' Functie ce calculeaza suma tranzactiilor de un anumit tip input : T - un tip, s - lista de tranzactii output : S - Suma tranzactiilor de un anumit tip ''' if lenght(s)==0: return 'Lista este goala!' S=0 for tz in s: if tz_anumit_tip(tz, T)==True: S+=get_suma(tz) return S
def UI_sold(s,us): while True: Z=input("Introduceti ziua: ") try: Z=int(Z) break except Exception as ex: print(ex) S=sv_sold(Z,s) if lenght(s)>0: print('Soldul de la data ',Z,' este: ',S) else: print(S)
def UI_sum_tip(s,us): while True: try: T=input("Introduceti tipul: ") if T!='intrare' and T!='iesire': raise Exception("Tip incorect!") break except Exception as ex: print(ex) S=sv_sum_tip(T,s) if lenght(s)>0: print('Suma tranzactiilor de tipul '+T+' este:') print(S) else: print(S)
def sv_sold(Z,s): ''' Functie ce calculeaza soldul contului la o data specificata input : Z - o zi, s - lista tranzactiilor iutput : S - soldul contului la o data specificata ''' if lenght(s)==0: return 'Lista este goala!' S=0 for tz in s: if get_zi(tz)<=Z: if get_tip(tz)=='intrare': S+=get_suma(tz) elif get_tip(tz)=='iesire': S-=get_suma(tz) return S