diff --git a/python/src/dish.py b/python/src/dish.py new file mode 100644 index 0000000..9fd4a80 --- /dev/null +++ b/python/src/dish.py @@ -0,0 +1,44 @@ +class Dish: + def __init__(self, name, vid, price): + self.__name = name + self.__vid = vid + self.check_price(price) + self.__price = price + + @property + def name(self): + return self.__name + + @property + def vid(self): + return self.__vid + + @property + def price(self): + return self.__price + + @name.setter + def name(self, value): + self.__name = value + + @vid.setter + def vid(self, value): + self.__vid = value + + @price.setter + def price(self, value): + self.check_price(value) + self.__price = value + + def check_price(self, price): + if price >= 5000 or price <= 0: + raise ValueError("Это блюдо вам не по карману") + + @property + def info(self): + return f"""Цена: {self.price} +Название: {self.name} +Тип блюда: {self.vid}""" + + + \ No newline at end of file diff --git a/python/src/main.py b/python/src/main.py index e37a77c..d77184a 100644 --- a/python/src/main.py +++ b/python/src/main.py @@ -1,7 +1,5 @@ -def summ(a: int, b: int) -> int: - return a + b - +from dish import Dish if __name__ == "__main__": - print("Hello world") - print(summ(3, 4)) + dish = Dish("Борщ", "Суп", 500) + print(dish.info) \ No newline at end of file