Answer the question
In order to leave comments, you need to log in
Did I write the code correctly?
I'm studying python and stopped at classes, so I'm trying to understand how they work in practice.
I chose character creation as the theme of the program. xD
Here is the class itself:
class person:
'''СОЗДАНИЕ ПЕРСОНАЖА'''
def __hero__(self, name):
self.name=name
self.cls=cls
self.gcls=gcsls
self.hp=hp
self.ghp=ghp
def clss(self):
cls=0
gcls=''
hp=0
ghp=[5 , 10 , 15 , 20]
if cls==1:
gcls+='Tank'
hp+=ghp[3]
elif cls==2:
gcls+='Heal'
hp+=ghp[0]
elif cls==3:
gcls+='Killer'
hp=ghp[2]
elif cls==4:
gcls+='Mage'
hp+=ghp[1]
else:
return 'Выберите персонажа'
clss()
from Person import *
print('\t\tСоздание персонажа\n\n')
person.name=input('Введите имя персонажа: ')
person.clss.cls=input('Выберите класс: \n [1] Tank \n [2] Heal \
\n [3] Killer \n [4] Mage \n\t>>>')
person.clss()
print('Персонаж создан!')
print('Имя: ' , person.name , '\n\nКласс: ' , person.clss.gcls , '\n\nHP: ' , person.clss.hp)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question