andrelievable

Untitled

May 20th, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. from decimal import *
  2. from datetime import datetime
  3.  
  4.  
  5. class Money:
  6.     def __init__(self, wartosc):
  7.         if wartosc in {0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50}:
  8.             self._wartosc = Decimal(str(wartosc))
  9.         else:
  10.             self._wartosc = Decimal('0')
  11.             print('nieznana moneta. przypisano wartosc 0zł')
  12.         self._waluta = 'PLN'
  13.  
  14.     def pobierz_wartosc(self):
  15.         return self._wartosc
  16.  
  17.     def pobierz_walute(self):
  18.         return self._waluta
  19.  
  20.  
  21. class Parkomat:
  22.     def __init__(self):
  23.         self._ListaMonet = []
  24.         self._AktualnyCzas = datetime.now()
  25.         self._CzasWyjazdu = self._AktualnyCzas
  26.         self._Rejestracja = ''
  27.         self._Suma = 0
  28.  
  29.     def ZliczanieMonet(self, moneta):
  30.         M = Money(moneta)
  31.         return self._ListaMonet.count(M)
  32.  
  33.     def DodajMonete(self, moneta):
  34.         self._ListaMonet.append(moneta)
  35.  
  36. m1=Money(0.2)
  37. P = Parkomat()
  38. P.DodajMonete(m1)
  39. print(P.ZliczanieMonet(0.2))
  40.  
Advertisement
Add Comment
Please, Sign In to add comment