Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education