1010class Worker ():
1111 def work (self ):
1212 print ("Estoy trabajando" )
13-
1413 def eat (self ):
1514 print ("Estoy comiendo" )
1615
@@ -78,15 +77,15 @@ def work(self):
7877 * 2. Aplica el ISP a la implementación.
7978 * 3. Desarrolla un código que compruebe que se cumple el principio.
8079"""
81-
8280class Printer (ABC ):
8381 @abstractmethod
84- def __init__ (self ,type ):
85- self . type = type
82+ def printer (self ,document ):
83+ print ( f"Imprimiento en Blanco y Negro el documento: \n { document } " )
8684
85+ class Color (ABC ):
8786 @abstractmethod
88- def printer (self ,document ):
89- print (f"Imprimiento en { self . type } el documento:\n { document } " )
87+ def print_color (self ,document ):
88+ print (f"Imprimiento en Color el documento:\n { document } " )
9089
9190class Scanner (ABC ):
9291 @abstractmethod
@@ -98,39 +97,35 @@ class Fax(ABC):
9897 def send_fax (self ,document ):
9998 print (f"Enviando por fax el documento: { document } " )
10099
101- class Regular_Printer (Printer ):
102- def __init__ (self ):
103- self . type = "Blanco y Negro"
100+ class RegularPrinter (Printer ):
101+ def printer (self , document ):
102+ return super (). printer ( document )
104103
105- def printer (self ,document ):
106- print (f"Imprimiendo en { self .type } el documento:\n { document } \n " )
104+ class ColorPrinter (Color ):
105+ def print_color (self , document ):
106+ return super ().print_color (document )
107107
108- class Color_Printer (Printer ):
109- def __init__ (self ):
110- self .type = "Color"
108+ class MultifunctionPrinter (Printer ,ColorPrinter ,Scanner ,Fax ):
111109
112110 def printer (self ,document ):
113- print (f"Imprimiendo en { self .type } el documento:\n { document } \n " )
114-
115- class Multifunction_Printer (Printer ,Scanner ,Fax ):
116- def __init__ (self ):
117- self .type = "Color"
111+ return super ().printer (document )
118112
119- def printer (self ,document ):
120- print ( f"Imprimiendo en { self . type } el documento: \n { document } \n " )
113+ def print_color (self , document ):
114+ return super (). print_color ( document )
121115
122- def scan (self ,document ):
123- print ( f"Escaneando documento { document } " )
116+ def scan (self , document ):
117+ return super (). scan ( document )
124118
125- def send_fax (self ,document ):
126- print ( f"Enviando el documento { document } por fax" )
119+ def send_fax (self , document ):
120+ return super (). send_fax ( document )
127121
128- my_regular_printer = Regular_Printer ()
129- my_color_printer = Color_Printer ()
130- my_multifunction_printer = Multifunction_Printer ()
122+ my_regular_printer = RegularPrinter ()
123+ my_color_printer = ColorPrinter ()
124+ my_multifunction_printer = MultifunctionPrinter ()
131125
132126my_regular_printer .printer ("Me llamo Alex" )
133- my_color_printer .printer ("Me llamo Alex" )
127+ my_color_printer .print_color ("Me llamo Alex" )
134128my_multifunction_printer .printer ("Me llamo Alex" )
129+ my_multifunction_printer .print_color ("Me llamo Alex" )
135130my_multifunction_printer .scan ("DNI de Alex" )
136131my_multifunction_printer .send_fax ("Nómina de Alex" )
0 commit comments