Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. from datetime import datetime, date, time
  2. from collections import Counter
  3. class my:
  4.     def __init__(self):
  5.         self.name=""
  6.         self.stuff=[]
  7.         self.temp=[]
  8.         self.history=[]
  9.     def set_name(self,str_name):
  10.         self.name=str_name
  11.         return self.name
  12.     def add_stuff(self,nameofstuff,price,code):
  13.         return self.stuff.append([nameofstuff,price,code,0])
  14.     def get_date(self):
  15.         return datetime.strftime(datetime.now(), "%Y.%m.%d %H:%M:%S")
  16.     def buy(self,code):
  17.         return self.temp.append(code)
  18.     def check(self):
  19.         temp1=[]
  20.         c = Counter(self.temp)
  21.         self.temp=list(set(self.temp))
  22.         for i in self.stuff:
  23.             if c[i[2]]!=0:
  24.                 i[3]=c[i[2]]
  25.                 temp1.extend(i[0])
  26.                 temp1.append(c[i[2]])
  27.                 a=i[1]*c[i[2]]
  28.                 temp1.append(a)
  29.         self.history.append(temp1[:])
  30.  
  31.     def cout(self):
  32.         k=2
  33.         summa=0
  34.         print('{:^20}'.format(self.name))
  35.         print('{0:^10}{1:^3}{2:^7}'.format("Товар","X","Цена"))
  36.         for i in self.history[-1]:
  37.             if k ==2 or k==1:
  38.                 if k==2:
  39.                     print(i,end=" ")
  40.                     k=k-1
  41.                 else:
  42.                     print('{0:>10}'.format(i),end=" ")
  43.                     k=k-1  
  44.             else:
  45.                 print('{:^5}'.format(i))
  46.                 k=2
  47.                 summa=summa+i
  48.         print("Сумма без НДС: ",summa)
  49.         print("Сумма НДС:    ",summa/10)
  50.         print("Сумма  c НДС: ",summa/10+summa)
  51.         print(self.get_date())
  52.  
  53. k=my()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement