Project to be completed in Python In this assignment you will be creating two different classes, Player and Enemy. Playe

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Project to be completed in Python In this assignment you will be creating two different classes, Player and Enemy. Playe

Post by answerhappygod »

Project to be completed in Python
In this assignment you will be creating two different classes,Player and Enemy.
Player
Your Player class will need to consist of the following:
Variables
• name
• health (HP)
• damage
• defense
Methods
• _init_( )
• character_create( ) – prompts the user to input values foreach of your attributes and displays chosen values back to user
• attack(Enemy) – receives a passed Enemy instance, and uses thestats of both Player and Enemy to cause damage to said Enemyinstance
Enemy
Enemy will inherit from your Player class. You will need toadd/modify the following:
Variables (new)
• type
Methods
• _init_( )
• character_create( ) – replaces the Player method topre-determined health, damage, and defense values based on thegiven Enemy type
• attack(Player) – overrides the Player method, allowing theenemy to perform their own attack calculations
Method Details:
1. Both Player and Enemy will implement a character_create( )method. Based on the class, the method should behavedifferently.
For the Player class, the user should simply be prompted toenter values for each of the aforementioned stats (name, health,damage, defense). Make sure that the user is correctly prompted fortheir input, and valid input ranges/values are outlined to them.Once complete, output the Player stats.
For the Enemy class, you will be overriding the basefunctionality of the Player methods. Rather than requesting theEnemy’s name, you will instead request the Enemy’s type. Based onthe user’s chosen type, the remaining attribute values (health,damage, defense) should be automatically assigned. For example:Possible enemy types are Minion, Brawler, and Elite. When selected:• Minion stats are automatically set to Health 10, Damage 2, andDefense 1. • Brawler stats are automatically set to Health 30,Damage 10, and Defense 5. • Elite stats are automatically set toHealth 100, Damage 20, and Defense 20. Once complete, output theEnemy stats. Note – Be sure to correctly prompt the user as to whatvalid Enemy types are accepted. Also, you are not required tochoose these specific types/values and may create any enemy typesyou like... be creative
2. Both of the classes will also need to implement anattack(Player/Enemy) method. This method should utilize the passedinstance to cause damage to the opposing object. For example, seethe following pseudocode for the Player attack method: defattack(enemy_object) enemy_health = enemy_health – (player_damage –enemy_defense) display new enemy_health You do not need to followthe above example exactly, as based on your inputted values, such acalculation may not be preferred. Please feel free to get creativewith your attack calculation, making it as simple or complex as youwish. To allow for further flexibility, the Enemy’s version ofattack should override the Player method, allowing the Enemy classto create its own attack implementation.
Behavior: Once both classes have been mergedinto a single file, you may add the following code to the bottom ofyour source file to execute the intended behavior. Note, that youmust be sure to use the same/proper naming conventions as outlinedprior to ensure proper execution:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply