Hardware' object has no attribute '_Hardware__quantity'
import datetime
from abc import ABC, abstractmethod
#############################################################################
# All your supplier classes (e.g. Item, Hardware, Software, and Borrower)
# must be implemented in this file
# You may start your implmention here
#############################################################################
# prevent compilation error in main application
class Item (ABC):
_list_item=list()
_borrrowd_no=0
@staticmethod
def get_list_item():
return Item._list_item
def __init__(self,name,vendor):
self.__name= name
self.__vendor= vendor
self._borrrowd_no= 0
Item._list_item.append(str(self.no_of_borrow()))
def borrowed(self,no_of_items):
self.__no_of_items= no_of_items
self.__no_of_items+=self._borrrowd_no
def get_vendor(self):
return self.__vendor
@abstractmethod
def is_available(self):
return NotImplemented
@abstractmethod
def no_of_borrow(self):
return NotImplemented
def __str__(self):
return f"{self.__name} "
def ruturned(self,no_of_items):
self.__no_of_items=no_of_items
return self.__no_of_items
class Hardware(Item):
def __init__(self,name,vendor,quantity):
super().__init__(name,vendor)
self.__quantity=quantity
def is_available(self,no_of_items):
self.__no_of_items=no_of_items
self.__no_of_items == True
if self.__no_of_items > self.__quantity:
return True
elif self.__no_of_items < self.__quantity:
print("Not available")
return False
def no_of_borrow(self):
return self._borrrowd_no(self.__quantity)
class Software(Item):
def __init__(self,name,vendor,no_of_licence,expiry_date):
super().__init__(name,vendor)
self.__no_of_licence=no_of_licence
self.__expiry_date=expiry_date
def is_expired(self):
now=date.today()
self.__expiry_date=now.strftime("%d/%m/%Y")
if self.__expiry_date >self.__expiry_date or self.__expiry_date == self.__expiry_date:
print("this software not expirted yet")
return False
else :
return True
def is_available(self,no_of_items):
self.__no_of_item=no_of_items
if self.__expirt_date ==0 and self.__no_of_licence > self.__no_of_items:
return True
if self.__no_of_item < self.__no_of_licence :
print("this is not analiable item to borrow")
return False
def no_of_borrow(self):
return "software"
class Borrower:
_list_borrower=list()
def __init__(self,name):
self.__name=name
self.__dict_item_borrowed={}
Borrower._list_borrower.append(self.__name,self.borrow_item())
def borrow_item(self,item,no_of_items):
self.__item=item
self.__no_of_items=no_of_items
def return_item(self,item,no_of_items):
return self.__item,self.__no_of_items
def dict_item_borrowed(self):
key=self.__dict_item_borrowed.update({self.__item:self.__no_of_items})
for item,value in key:
if item in key.keys() and value in key.values() :
return True
else:
print("invalid value")
return False
def get_dict_item_borrowed(self):
return key
@staticmethod
def get_list_borrower():
return Borrower._list_borrower
def __str__(self):
return f" {self.__name}"
Hardware' object has no attribute '_Hardware__quantity'