1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Object-Oriented Programming in Python

Connected

Exercise

Informal interfaces

Informal interfaces provide a set of methods that must be defined in all classes that implement that interface. Below is a class named Supplier that will act as an informal interface. In order for YogurtSupplier to fulfill the contract set out by the Supplier interface, it must define the methods take_order() and make_delivery(). In this exercise, you'll practice doing just that.

class Supplier:
  def take_order(self, product_name, quantity):
    pass

  def make_delivery(self, order_id, location):
    pass

Instructions

100 XP
  • In the YogurtSupplier class, define the take_order() method to add an order to the self.orders dictionary.
  • Complete the contract set out by the Supplier interface by defining a make_delivery() method to print a message and delete the order stored using order_id from self.orders.