You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1000 B
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""Реализация дескриптора с комиссией"""
class Value:
"""Значение"""
def __init__(self):
"""Конструктор класса"""
self.amount: "float" = 0.0
def __get__(self, obj, obj_type) -> "float":
"""Возвращение значения"""
return self.amount
def __set__(self, obj, value):
"""Присваивание значения"""
self.amount = value - value * obj.commission
class Account:
"""Счет"""
amount: "Value" = Value()
def __init__(self, commission):
"""Конструктор класса"""
self.commission: "float" = commission
def __str__(self) -> "str":
"""Строковое представление класса"""
return f"{self.commission}"
def __repr__(self) -> "str":
"""Строковое представление класса"""
return f"Account({self.commission})"