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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter5: Making Decisions
Section: Chapter Questions
Problem 8PE
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage