100%(4)4 out of 4 people found this document helpful
This preview shows page 1 - 3 out of 12 pages.
10.1 CS 172 - Lab 4Monster BattleIn this lab we will create a battle game. Two objects that inherit from an abstract Monsterclass will fight.Provided CodeYou are provided with two files. Study each file before creating your own classes.monster.py- This contains an abstract base class, Monsterthat can be derived from in order to have character participate in the game. Ultimately you will also put your derived class in this module.main.py- The main program. This program allows two monsters to battle and determines the winner.The ClassesYour first task is to create a CustomMonsterclass that derives from a provided abstract Monsterclass. You will NOT change the code in Monster Class. You will change the code in the CustomMonster Class. Let's first look at the structure now.The CustomMonster Class:The CustomMonster class is a class that inherits from a pure abstract classwhich is the Monster class(all of its methods are abstract and generic) Below are the methods requiredto be implemented in your CustomMonster class. (In ZyBooks you will see the TODO statements as well)Let's take a look at the attributes in your CustomMonsterclass.self.__name : This attribute is the name of the monster.self.__maximumHealth : This attribute is the maximum health of the monster.self.__health :This attribute is the current health of the monster.self.__description: This attribute is the description of the monster.self.__basicAttackDamage : This attribute is the damage(int) that this monster deals to the other monster during its basic attack.self.__specialAttackDamage: This attribute is the damage(int) that this monster deals to the other monster during its special attack.self.__defenseDamage : This attribute is the damage(int) that this monster deals to the other monster during its defense.self.__basicAttackName : This attribute is the name of its basic attack.(str)self.__specialAttackName: This attribute is the name of its basic attack.(str)self.__basicDefenseName : This attribute is the name of its basic attack.(str)Let's take a look at the methods in your CustomMonsterclass. Constructor:
def __init__(self,n, health=100, description = 'Fast and Furious Fur Ball', basicAttackDamage=7, specialAttackDamage=10, defenseDamage=1, basicAttackName='scratch', specialAttackName='special scratch', basicDefenseName='duck'): The parameters of this constructor method are described as follows (with their type in parenthesis):Explanation of each parameter in your init:n(str) is the namehealth(int) is the startinghealth of the monster. This constructor input needs to be used to define the maximum health of the monster. You also need to find a way to keep track of the current health of the monster after each attack/defense. If this is confusing, think of it this way, there needs to be two attributes in your custom monster class, one for the current health of the monster, one for the maximum health of the monster and initially current health is equal to the maximum health which is equal to the health that was passed as input to constructor.