无法用抽象方法getadmincharge、getfinesperday示例化抽象类项不能的

3wabscal  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(193)
  1. from abc import ABC, abstractmethod
  2. import datetime
  3. from typing import List
  4. class Item(ABC):
  5. _loanDuration = 14
  6. @classmethod
  7. def getLoanDuration(cls):
  8. return cls._loanDuration
  9. @classmethod
  10. def setLoanDuration(cls, newDuration):
  11. cls._loanDuration = newDuration
  12. def __init__(self, title: str, yearPublished: int, cost: float):
  13. self._title = title
  14. self._yearPublished = yearPublished
  15. self._cost = cost
  16. @property
  17. def title(self):
  18. return self._title
  19. @property
  20. def yearPublished(self):
  21. return self._yearPublished
  22. @property
  23. def cost(self):
  24. return self._cost
  25. @abstractmethod
  26. def getAdminCharge(self):
  27. return self.getAdminCharge
  28. @abstractmethod
  29. def getFinesPerDay(self):
  30. return self.getAdminCharge
  31. def lostCharges(self):
  32. return self.getAdminCharge() + self._cost
  33. def __str__(self):
  34. return f"{self._title} {self._yearPublished} Cost: ${self._cost}"
  35. C1 = Item("Asia Food And Culture","2019","30")
  36. print(C1)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题