1 |
class Student: |
2 |
def __init__(self, name, age, branch): |
3 |
self.__name = name |
4 |
self.__age = age |
5 |
self.__branch = branch |
6 |
def __display_details(self): |
7 |
print(f'Имя: {self.__name}') |
8 |
print(f'Возраст: {self.__age}') |
9 |
print(f'Направление: {self.__branch}') |
10 |
def access_private_method(self): |
11 |
self.__display_details() |
12 |
class BankAccount: |
13 |
def __init__(self, number, balance): |
14 |
self._account_number = number |
15 |
self._balance = balance |
16 |
def get_account_number(self): |
17 |
return self._account_number |
18 |
def get_balance(self): |
19 |
return self._balance |
20 |
def set_balance(self, new_balance): |
21 |
a, b, c = map(float, input().split()) |
22 |
class Employee: |
23 |
def __init__(self, name, salary): |
24 |
self.__name = name |
25 |
self.__salary = salary |
26 |
def __get_name(self): |
27 |
return self.__name |
28 |
def __get_salary(self): |
29 |
return self.__salary |
30 |
def __set_salary(self, value): |
31 |
if not isinstance(value, (int, float)) or value < 0: |
32 |
print(f'ErrorValue:{value}') |
33 |
return |
34 |
self.__salary = value |
35 |
title = property(fget=__get_name) |
36 |
reward = property(fget=__get_salary, fset=__set_salary) |
37 |
self._balance = new_balance |
Комментарии