fork download
  1. class BankAccount:
  2. count_condition = 0.0
  3. def get_cond(self):
  4. return self.__class__.count_condition
  5.  
  6. def add(self, value):
  7. self.__class__.count_condition += value
  8.  
  9. def __init__(self, name, number_count):
  10. self.name = name
  11. self.number_count = number_count
  12. self.valid_count = 328475
  13.  
  14. def showCount(self, number_count):
  15. if self.number_count == self.valid_count:
  16. return round(self.get_cond(), 1)
  17. else:
  18. return "Wrong count number!"
  19.  
  20. def addMoney(self, number_count, money_count):
  21. if self.number_count == self.valid_count:
  22. self.add(money_count)
  23. else:
  24. return "Error!"
  25.  
  26. def minusMoney(self, number_count, money_count):
  27. if self.number_count == self.valid_count:
  28. self.add (-money_count)
  29. else:
  30. return "Error!"
  31.  
  32.  
  33. class InterestAccount(BankAccount):
  34. def addInterest(self, procent):
  35. if self.get_cond() > 0:
  36. return (self.get_cond() / 100) * procent
  37.  
  38.  
  39. myCount = BankAccount("One", 328475)
  40. myCount.addMoney(328475, 45.5)
  41. print(myCount.showCount(328475))
  42. myCount.minusMoney(328475, 1.3)
  43. print(myCount.showCount(328475))
  44. myProcent = InterestAccount("One", 328475)
  45. print(myProcent.addInterest(7))
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
45.5
44.2
3.094