Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON INHERITANCE LAB You will create a class that inherits from the following Pokemon class. class Pokemon: basic _ attack = 'tackle' damage = 4
PYTHON INHERITANCE LAB
You will create a class that inherits from the following Pokemon class.
class Pokemon:
basicattack 'tackle'
damage ;
def initself name, trainer:
self.name name
self.trainer trainer
self.level
self.hp
self.paralyzed False
def speakself:
printselfname
def attackself other:
if not self.paralyzed:
self.speak
printselfname, used self.basicattack,
other.receivedamageselfdamage
def receivedamageself damage:
self.hp max self.hp damage
if self.hp :
printselfname, fainted!
The above video lecture includes an example of a class that inherits from the Pokemon class for Electric type Pokemon. You can use this example to help you build your own Pokemon type, but be careful to follow the requirements listed below because there are some important differences.
Create a class that inherits from the Pokemon class. This class will be a type of Pokemon from this list:
Type basicattack prob Strong Against Weak Against
Normal Body Slam
Ghost
Flying Bounce
Fighting, Bug, Grass, Fairy
Electric
Dragon Dragon Breath
Dark Fling Ghost, Psychic Fighting, Dark, Fairy
Fighting Fling Normal, Ice, Dark Bug, Dark
Ice Freeze Shock Flying, Grass, Dragon Fire, Water, Ice
Ghost Lick
Psychic Psychic Shift Fighting, Poison Bug, Ghost, Dark
Bug Signal Beam Grass, Psychic, Dark Fighting, Flying, Poison, Ghost, Fire, Fairy
Fairy Sweet Kiss
Fighting, Dragon, Dark
Poison, Fire
Fire Blaze Kick Bug, Grass, Ice Fire, Water, Dragon
Poison Poison Jab Grass, Fairy Poison, Ghost
Electric Thunder Shock
Water Splishy Splash
Grass Stun Spore Water Flying, Poison, Bug, Fire, Grass
Choose the Pokemon type that contains the first letter of your first, middle or last name and create a class for that pokemon that inherits from the Pokemon class. For example, if your first, middle or last name starts with the letter R you might choose to create a class for a pokemon type that contains the letter R like a Rock class or a Water class, which both contain the letter R If you cannot find a pokemon type that contains the first letter of your first, middle or last name, choose Bug.
Post your class to this discussion as a py attachment or provide a link to the github repository for your code. The py file should import the base class and include your complete subclass code. As soon as you post your code, you will unlock all of the other posts to see the classes created by your fellow students. You will then choose one or more classes posted to the discussion by your classmates and download the code to use for Project
Implementation Requirements For Your Class:
Create class named after the type of Pokemon you selected, which inherits from the Pokemon class and has the additional instance attributes, basicattack and prob probability
Define init and str to take the basicattack and probability into account. These methods are not defined in the video lecture. You will need to add them to your Pokemon type. The init method must accept the hp as a parameter because it can be different for each Pokemon instance.
Define attack for your type. Use isinstance to check the instance type. See the example in the Polymorphism section of the lecture slides lecture week apdf Download lecture week apdf
The attack method can inflict paralysis if your Pokemon type is Normal, Flying, Dragon, Dark, Fighting, Ice, Ghost, Psychic, Water, Grass or Electric. Follow the lecture video example on how to implement the paralyze feature in the attack method if you have one of these Pokemon type.
If your Pokemon type is Bug or Fairy, use the prob to inflict confusion instead. Follow the example for paralyzing an opponent, but with the message: printothername, is confused'
If your Pokemon type is Fire use the prob to inflict a burn instead. Follow the example for paralyzing an opponent, but with the message: printothername, is burned'
If your Pokemon type is Poison, use the prob to poison the opponent. Follow the example for paralyzing an opponent, but with the message: printothername, is poisoned'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started