Advertisement
aneliabogeva

to be continue

Jul 29th, 2019
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. from abc import ABC
  2.  
  3. class Computer_store(ABC):
  4. def __init__(self, brand: str, id:int, ram: int, cores: int):
  5. self.brand = brand
  6. self.id = id
  7. self.ram = ram
  8. self.cores = cores
  9.  
  10.  
  11. class Laptop(Computer_store):
  12. def __init__(self, brand: str, id: int, ram: int, cores: int, sub_brand: str):
  13. Computer_store.__init__(self,brand,id, ram, cores)
  14. self.sub_brand = sub_brand
  15.  
  16. class PC(Computer_store):
  17. def __init__(self, brand, id, ram, cores, serial_number: int):
  18. Computer_store.__init__(self, brand, id, ram, cores)
  19. self.serial_number = serial_number
  20.  
  21.  
  22. laptop = []
  23. pc = []
  24. command = input().split('(')
  25. while not command[0] == 'end':
  26. if command[0] == 'Laptop':
  27. row1 = command[1].split(')')
  28. param_list = row1[0].split(', ')
  29. if len(param_list) < 5:
  30. print(f'__init__() missing 1 required positional argument:\'sub_brand\'')
  31. elif param_list[4].isdigit():
  32. print('sub_brand must be string')
  33. else:
  34. object = Laptop(param_list[0],param_list[1],param_list[2],param_list[3],param_list[4])
  35. laptop.append(object)
  36. elif command[0] == 'PC':
  37. row1 = command[1].split(')')
  38. param_list = row1[0].split(', ')
  39. if len(param_list) < 5:
  40. print(f'__init__() missing 1 required positional argument:\'serial_number\'')
  41. elif param_list[4].isalpha():
  42. print('serial_number must be int')
  43. else:
  44. object = PC(param_list[0], param_list[1], param_list[2], param_list[3], param_list[4])
  45. pc.append(object)
  46. else:
  47. print(f'instantiate abstract class Computer with abstract methods __init__')
  48. command = input().split('(')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement