#!/usr/bin/env python # -*- coding: utf-8 -* import abc class Scanner(abc.ABC): def __init__(self): self.scanner_resolution = 100 @abc.abstractmethod def scan_document(self) -> str: pass @abc.abstractmethod def get_scanner_status(self) -> str: pass class Printer(abc.ABC): def __init__(self): self.printer_resolution = 100 self.printer_operation_history = False self.fax_machine = False @abc.abstractmethod def print_document(self) -> str: pass @abc.abstractmethod def get_printer_status(self) -> str: pass class MFD(): def __init__(self,serial_number=""): self.serial_number = serial_number def scan_document(self): print("El document ha estat escanejat") def get_scanner_status(self): fax = "" if self.fax_machine == False else ", Fax" print( "màxima resolució scanner: {}{} número de sèrie:{}".format(self.scanner_resolution,fax,self.serial_number) ) def print_document(self): print("El document ha estat imprés") def get_printer_status(self): poh = "" if self.printer_operation_history == False else ", Històric d'impressora" print( "màxima resolució impressora: {}{} número de sèrie:{}".format(self.scanner_resolution,poh,self.serial_number) ) class MFD1(MFD,Scanner,Printer): def __init__(self,serial_number=""): MFD.__init__(self,serial_number) Scanner.__init__(self) Printer.__init__(self) self.low() def low(self): self.scanner_resolution = 100 self.printer_resolution = 100 self.printer_operation_history = False self.fax_machine = False class MFD2(MFD,Scanner,Printer): def __init__(self,serial_number=""): MFD.__init__(self,serial_number) Scanner.__init__(self) Printer.__init__(self) self.medium() def medium(self): self.scanner_resolution = 300 self.printer_resolution = 300 self.printer_operation_history = True self.fax_machine = False class MFD3(MFD,Scanner,Printer): def __init__(self,serial_number=""): MFD.__init__(self,serial_number) Scanner.__init__(self) Printer.__init__(self) self.high() def high(self): self.scanner_resolution = 600 self.printer_resolution = 600 self.printer_operation_history = True self.fax_machine = True d1 = MFD1("d1-sn") d1.get_scanner_status() d1.get_printer_status() d2 = MFD2("d2-sn") d2.get_scanner_status() d2.get_printer_status() d3 = MFD3("d3-sn") d3.get_scanner_status() d3.get_printer_status()