#!/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 class MFD1(MFD,Scanner,Printer): def __init__(self,serial_number=""): MFD.__init__(self,serial_number) Scanner.__init__(self) Printer.__init__(self) def low(self): self.scanner_resolution = 100 self.printer_resolution = 100 self.printer_operation_history = False self.fax_machine = False def medium(self): self.scanner_resolution = 300 self.printer_resolution = 300 self.printer_operation_history = True self.fax_machine = False def high(self): self.scanner_resolution = 600 self.printer_resolution = 600 self.printer_operation_history = True self.fax_machine = True 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) ) d1 = MFD1("d1-sn") d1.low() d1.get_scanner_status() d1.get_printer_status() d2 = MFD1("d2-sn") d2.medium() d2.get_scanner_status() d2.get_printer_status() d3 = MFD1("d3-sn") d3.high() d3.get_scanner_status() d3.get_printer_status()