generated from ISUCT/Algorithm_2023
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}""" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |