Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from abc import ABC
- class Computer_store(ABC):
- def __init__(self, brand: str, id:int, ram: int, cores: int):
- self.brand = brand
- self.id = id
- self.ram = ram
- self.cores = cores
- class Laptop(Computer_store):
- def __init__(self, brand: str, id: int, ram: int, cores: int, sub_brand: str):
- Computer_store.__init__(self,brand,id, ram, cores)
- self.sub_brand = sub_brand
- class PC(Computer_store):
- def __init__(self, brand, id, ram, cores, serial_number: int):
- Computer_store.__init__(self, brand, id, ram, cores)
- self.serial_number = serial_number
- laptop = []
- pc = []
- command = input().split('(')
- while not command[0] == 'end':
- if command[0] == 'Laptop':
- row1 = command[1].split(')')
- param_list = row1[0].split(', ')
- if len(param_list) < 5:
- print(f'__init__() missing 1 required positional argument:\'sub_brand\'')
- elif param_list[4].isdigit():
- print('sub_brand must be string')
- else:
- object = Laptop(param_list[0],param_list[1],param_list[2],param_list[3],param_list[4])
- laptop.append(object)
- elif command[0] == 'PC':
- row1 = command[1].split(')')
- param_list = row1[0].split(', ')
- if len(param_list) < 5:
- print(f'__init__() missing 1 required positional argument:\'serial_number\'')
- elif param_list[4].isalpha():
- print('serial_number must be int')
- else:
- object = PC(param_list[0], param_list[1], param_list[2], param_list[3], param_list[4])
- pc.append(object)
- else:
- print(f'instantiate abstract class Computer with abstract methods __init__')
- command = input().split('(')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement