Skip to content

Commit

Permalink
lab classes on python
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetfyx committed Feb 16, 2024
1 parent 6339027 commit b551422
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
44 changes: 44 additions & 0 deletions python/src/dish.py
Original file line number Diff line number Diff line change
@@ -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}"""



8 changes: 3 additions & 5 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b551422

Please sign in to comment.