Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 5 Python Pribylov #45

Open
wants to merge 1 commit into
base: Pribylov_Aleksej_Aleksandrovich
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions python/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Character:
def __init__(self, name, clas, lvl):
self.name = name
self.clas = clas
if lvl < 0:
raise 'Начальный уровень не может быть отрицательным'
else:
self.lvl = lvl

def set_name(self, new_name):
self.name = new_name

def set_clas(self, new_clas):
self.clas = new_clas

def set_lvl(self, new_lvl):
if new_lvl < 0:
raise 'Начальный уровень не может быть отрицательным'
else:
self.lvl = new_lvl

def get_name(self):
return self.name

def get_clas(self):
return self.clas

def get_lvl(self):
return self.lvl
13 changes: 7 additions & 6 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
def summ(a: int, b: int) -> int:
return a + b
from __init__ import Character


if __name__ == "__main__":
print("Hello world")
print(summ(3, 4))
if __name__ == '__main__':
char = Character('Alduin', 'Berserk', 20)
print(char.get_name(), char.get_clas(), char.get_lvl())
char.set_lvl(30)
char.set_clas('Hunt')
print(char.get_name(), char.get_clas(), char.get_lvl())