inheritance - python calling a super class method in a subclass method with arguments=None -


i want create class called shoppingcart method remove_item(self, item_name, quantity, price).

i want create subclass shop of superclass shoppingcart , in shop class, override remove_item method, such calling shop's remove_item no arguments decrements quantity one.

class shoppingcart(object):     def __init__(self):       self.total = 0       self.items = {}      def add_item(self, item_name, quantity, price):       self.total += price * quantity       self.items[item_name] = quantity      def remove_item(self, item_name, quantity, price):       if quantity> self.items[item_name]:         quantity = self.items[item_name]         del self.items[item_name]       else:         new_quantity =  self.items[item_name] - quantity         self.items[item_name] = new_quantity       self.total-=quantity*price       def checkout(self, cash_paid):       if cash_paid < self.total:         return "cash paid not enough"       balance = cash_paid - self.total       return balance  class shop(shoppingcart):     def __init__(self):       self.quantity = 100       #shoppingcart.__init__(self)       super(shop,self).__init__()      def remove_item(self, item_name=none, quantity=none, price=none):         self.quantity -= 1         super(shop, self).remove_item(item_name,quantity,price) 


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -