Предмет: Информатика, автор: radchenkopolina2008

Створити ще одного чарівника, як екземпляр класу у цій же програмі.
*Додати фрагмент програми, у якому чарівники виконають по одній дії (методу) і визначити переможця за більшою кількістю мани
Пожалуйста сделайте в пайтоне. Сделать нужно на основе фото. Даю 100 балов

Приложения:

Ответы

Автор ответа: anonymous2010
1

wizards = []

class Wizard():

   def __init__(self, name:str='', power:int=0) -> None:

       if name in [wizard.name for wizard in wizards] or name == '':

           self.name = 'wizard'+str(len(wizards)+1)

       else:

           self.name = name

           

       self.power = power

       wizards.append(self)

   def upPower(self, mana:int=0) -> None:

       self.power += mana

   def downPower(self, mana:int=0) -> None:

       self.power -= mana

   def __str__(self) -> str:

       return f"name: {self.name}; power: {self.power}"

def magic(wizard:Wizard=None) -> None:

   print(wizard)

   if input('1-чарівник чаклує, 2-чарівник випив зілля: ')=='1':

       wizard.downPower(50)

   else:

       wizard.upPower(50)

def main() -> None:

   Wizard('wizard1', 500)

   Wizard('wizard2', 500)

   for wizard in wizards:

       magic(wizard=wizard)

   winner: Wizard = max(wizards, key=lambda x:x.power)

   print('переможець:', winner.name)

if __name__ == '__main__':

   main()


anonymous2010: можеш скіки хош тих візардів добавить
Похожие вопросы
Предмет: Английский язык, автор: fevziez17
Reading 9 Read the text. Match sentences A-E with gaps 1-5. One child families are they good for us? Have you got any brothers or sisters? Parents in China are excited about the news that now they can have more than one child. So how are family sizes different around the world? In Europe, the average family has two children. In Turkey, parents usually have three children. Most American families have two children. But the American actors Angelina Jolie and Brad Pitt are famous for their very big family. They have three children and three other children from different countries. Zahara comes from Ethiopia, Pax comes from Vietnam and Maddox comes from Cambodia. - According to research, a sister or brother is an advantage. You can talk to your brother or sister when you are worried about your problems. You can learn lots of things from your siblings. And learning how to get on with each other can teach you life skills too. What about only children? They don't have brothers or sisters to learn from or share with. 4. People say that only children can't share and are not friendly. However, according to lots of studies, only children are no different from children with siblings. They learn to share in the classroom, or with cousins, step-brothers and step-sisters and their friends. 5 The answer is yes. Only children usually get on very well with their parents and they are very independent.
A Four out of five children in the USA have brothers or sisters.
B Many of the parents of only children worry about this.
C So do only children get benefits?
D Or are you an only child?
E They can teach you new facts.​