Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from multipledispatch import dispatch
- from abc import abstractmethod
- class Table:
- def __init__(self, l, w, h):
- self.length = l
- self.width = w
- self.high = h
- self._color = ""
- self._material = ""
- @property
- def color(self):
- if self._color == "":
- return "Цвет не задан"
- return self._color
- @color.setter
- def color(self, color):
- self._color = color
- @property
- def material(self):
- if self._material == "":
- return "Материал не задан"
- return self._material
- @material.setter
- def material(self, material):
- self._material = material
- @abstractmethod
- def get_square(self):
- pass
- @dispatch()
- def get_high(self):
- return self.high
- @dispatch(int)
- def get_high(self, shelf_height):
- return self.high + shelf_height
- @abstractmethod
- def add_shelf(self, shelf_high):
- pass
- @abstractmethod
- def get_shelfHeight(self):
- pass
- @staticmethod
- def about():
- print('вероятнее всего, это что-то связанное со столами')
- @staticmethod
- def kufar_find_bookTable():
- print("Столов-книжек в радиусе 100 км не обнаружено")
- @abstractmethod
- def info(self):
- return 'Некоторый стол'
- class KitchenTable(Table):
- @dispatch(int, int, int)
- def __init__(self, l, w, h):
- super().__init__(l, w, h)
- self._places = 4
- @dispatch(int, int, int, int)
- def __init__(self, l, w, h, pl=4):
- super().__init__(l, w, h)
- self._places = pl
- @property
- def places(self):
- return self._places
- @places.setter
- @places.setter
- def places(self, places):
- self._places = places
- def info(self):
- return 'Кухонный стол'
- def get_square(self):
- return self.length * self.width
- # places = property(get_places, set_places)
- class DeskTable(Table):
- def __init__(self, l, w, h):
- super().__init__(l, w, h)
- self._shelf = []
- def get_square(self):
- return self.length * self.width
- def add_shelf(self, shelf_high):
- self._shelf.append(shelf_high)
- def get_shelfHeight(self):
- if len(self._shelf) == 0:
- return "Полок не обнаружено"
- sum = 0
- for element in self._shelf:
- sum += element
- return sum / len(self._shelf)
- def info(self):
- return "Письменный стол"
- class ComputerTable(DeskTable):
- def __init__(self, l, w, h, restSquare=0):
- super().__init__(l, w, h)
- self._restSquare = restSquare
- def get_square(self):
- return super().get_square() - self._restSquare
- def info(self):
- return 'Компьютерый стол'
- lst = []
- quant = int(input('Введите количество столов: '))
- for iter in range(quant):
- Type = int(input('Какой стол вы хотите создать? \n 1 - Кухонный\n 2 - Письменный\n 3 - Компьютерный\n'))
- if Type == 1:
- print('Введите Длину, ширину, высоту, кол-во мест (по умолчанию 4):')
- args = input()
- argslst = []
- temp = None
- for arg in args.split():
- argslst.append(int(arg))
- if len(argslst) == 3:
- temp = KitchenTable(argslst[0], argslst[1], argslst[2])
- lst.append(temp)
- elif len(argslst) == 4:
- temp = KitchenTable(argslst[0], argslst[1], argslst[2], argslst[3])
- lst.append(temp)
- else:
- print('Неверные входные данные!\n')
- elif Type == 2:
- print('Введите Длину, ширину, высоту:')
- args = input()
- argslst = []
- temp = None
- for arg in args.split():
- argslst.append(int(arg))
- if len(argslst) == 3:
- temp = DeskTable(argslst[0], argslst[1], argslst[2])
- lst.append(temp)
- else:
- print('Неверные входные данные!')
- elif Type == 3:
- print('Введите Длину, ширину, высоту, площадь, занимаемая компьютером:')
- args = input()
- argslst = []
- temp = None
- for arg in args.split():
- argslst.append(int(arg))
- if len(argslst) == 3:
- temp = ComputerTable(argslst[0], argslst[1], argslst[2])
- lst.append(temp)
- elif len(argslst) == 4:
- temp = ComputerTable(argslst[0], argslst[1], argslst[2], argslst[3])
- lst.append(temp)
- else:
- print('Неверные входные данные!')
- if len(lst) != 0:
- for element in lst:
- print(element.info())
- element.color = "blue"
- print(element.color)
- print(element.get_square())
Advertisement
Add Comment
Please, Sign In to add comment