From fb0521aa05240b1b3b01fdf5c73b9e8a7c273ee8 Mon Sep 17 00:00:00 2001 From: Vitor Buxbaum Date: Fri, 2 Apr 2021 19:20:33 -0300 Subject: [PATCH] =?UTF-8?q?1.15=20-=20Implementa=C3=A7=C3=A3o=20e=20decis?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1_introducao/15_interface_item.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 1_introducao/15_interface_item.py diff --git a/1_introducao/15_interface_item.py b/1_introducao/15_interface_item.py new file mode 100644 index 0000000..4fc8574 --- /dev/null +++ b/1_introducao/15_interface_item.py @@ -0,0 +1,18 @@ +""" +Python não oferece a implementação explícita de interfaces, como Java, mas o +mesmo comportamento pode ser replicado de duas formas principais. +""" + + +from abc import ABC, abstractmethod + + +class Item1(object): + def __gt__(self, outro_item): + raise NotImplementedError() + + +class Item2(ABC): + @abstractmethod + def create_purchase_invoice(self, purchase): + pass