0
from abc import ABC, abstractmethod
import datetime
from typing import List

class Item(ABC):
    _loanDuration = 14    

    @classmethod
    def getLoanDuration(cls):
        return cls._loanDuration
    
    @classmethod
    def setLoanDuration(cls, newDuration):
        cls._loanDuration = newDuration

    def __init__(self, title: str, yearPublished: int, cost: float):
        self._title = title
        self._yearPublished = yearPublished
        self._cost = cost

    @property
    def title(self):
        return self._title

    @property
    def yearPublished(self):
        return self._yearPublished

    @property
    def cost(self):
        return self._cost

    @abstractmethod
    def getAdminCharge(self):
        return self.getAdminCharge
    
    @abstractmethod
    def getFinesPerDay(self):
        return self.getAdminCharge
    
    def lostCharges(self):
        return self.getAdminCharge() + self._cost

    def __str__(self):
        return f"{self._title} {self._yearPublished} Cost: ${self._cost}"
    
C1 = Item("Asia Food And Culture","2019","30")
    
print(C1)
Asocia
  • 5,935
  • 2
  • 21
  • 46
md noh
  • 9
  • Unable to execute the code, tried to Print C1 keep getting, Can't instantiate abstract class Item with abstract methods getAdminCharge, getFinesPerDay – md noh Apr 27 '21 at 22:19
  • Could you comment on why you're using `abstractmethod` and `ABC` here if you want to actually instantiate `Item`? – Brian61354270 Apr 27 '21 at 22:20

0 Answers0