In this problem, you will define a class to represent a competitor in a wizard battle. Your class should be named Wizard, and you should define the methods below. Hint: if you are using the print or input functions to implement these methods, you are doing it wrong. __init__: Initializes an Wizard object. Takes four parameters: the name of the wizard (a string), their age (an integer), their animal familiar’s name (a string), and their power level (an integer). These are saved in appropriate attributes. In addition, it initializes the following attributes: a Boolean value indicating if the competitor is cursed (initially False ), an integer indicating the number of potions the wizard has (initially 2). __str__: Returns a string summarizing the Wizard object, following the format below exactly: Merlin with Archimedes the Owl (205 power, 2 potions) You should use values derived from attributes in place of the bolded values. __lt__: Compares self to another Wizard object. It returns True if self is younger than the other Wizard object, and False otherwise. get_name: Returns the name of the wizard. get_power: Returns the wizard’s current power. add_potion: Increases the number of potions by one. This method has no return value. drink_potion: If the wizard has a potion, it drinks one (decrementing it from the potions counter) to increase the wizard power by 100 and remove any curse. This method has no return value. lose_power: Takes one parameter, the amount of power the wizard will lose. The wizard loses this amount of power. If this leaves the wizard with negative power, then the power is set to zero. This method has no return value. attack: The current wizard attacks a target. Takes another Wizard object as a parameter. Returns a Boolean value indicating if the attack succeeded or failed. If the current wizard is cursed or has less than 100 power, their attack fails. Otherwise, the attack succeeds: they lose 100 power and the other wizard loses 200 power.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
In this problem, you will define a class to represent a competitor in a wizard battle. Your class should be named Wizard, and you should define the methods below. Hint: if you are using the print or input functions to implement these methods, you are doing it wrong.

__init__: Initializes an Wizard object. Takes four parameters: the name of the wizard (a string), their age (an integer), their animal familiar’s name (a string), and their power level (an integer). These are saved in appropriate attributes. In addition, it initializes the following attributes: a Boolean value indicating if the competitor is cursed (initially False ), an integer indicating the number of potions the wizard has (initially 2).

__str__: Returns a string summarizing the Wizard object, following the format below exactly: Merlin with Archimedes the Owl (205 power, 2 potions) You should use values derived from attributes in place of the bolded values.

__lt__: Compares self to another Wizard object. It returns True if self is younger than the other Wizard object, and False otherwise.

get_name: Returns the name of the wizard.

get_power: Returns the wizard’s current power.

add_potion: Increases the number of potions by one. This method has no return value.

drink_potion: If the wizard has a potion, it drinks one (decrementing it from the potions counter) to increase the wizard power by 100 and remove any curse. This method has no return value.

lose_power: Takes one parameter, the amount of power the wizard will lose. The wizard loses this amount of power. If this leaves the wizard with negative power, then the power is set to zero. This method has no return value.

attack: The current wizard attacks a target. Takes another Wizard object as a parameter. Returns a Boolean value indicating if the attack succeeded or failed. If the current wizard is cursed or has less than 100 power, their attack fails. Otherwise, the attack succeeds: they lose 100 power and the other wizard loses 200 power.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education