In this assignment you will be creating two different classes, Player and Enemy. Player Your Player class will need to c

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

In this assignment you will be creating two different classes, Player and Enemy. Player Your Player class will need to c

Post by answerhappygod »

In this assignment you will be creating two different classes,Player and Enemy.PlayerYour Player class will need to consist of the following:Variables• name• health (HP)• damage• defenseMethods• _init_( )• character_create( ) – prompts the user to input values for eachof your attributes and displayschosen values back to user• attack(Enemy) – receives a passed Enemy instance, and uses thestats of both Player and Enemyto cause damage to said Enemy instanceEnemyEnemy will inherit from your Player class. You will need toadd/modify the following:Variables (new)• typeMethods• _init_( )• character_create( ) – replaces the Player method topre-determined health, damage, anddefense values based on the given Enemy type• attack(Player) – overrides the Player method, allowing the enemyto perform their own attackcalculations
Method Details: 1. Both Player and Enemy will implement acharacter_create( ) method. Based on the class, the method shouldbehave differently. For the Player class, the user should simply beprompted to enter values for each of the aforementioned stats(name, health, damage, defense). Make sure that the user iscorrectly prompted for their input, and valid input ranges/valuesare outlined to them. Once complete, output the Player stats. Forthe Enemy class, you will be overriding the base functionality ofthe Player methods. Rather than requesting the Enemy’s name, youwill instead request the Enemy’s type. Based on the user’s chosentype, the remaining attribute values (health, damage, defense)should be automatically assigned. For example: Possible enemy typesare Minion, Brawler, and Elite. When selected: • Minion stats areautomatically set to Health 10, Damage 2, and Defense 1. • Brawlerstats are automatically set to Health 30, Damage 10, and Defense 5.• Elite stats are automatically set to Health 100, Damage 20, andDefense 20. Once complete, output the Enemy stats. Note – Be sureto correctly prompt the user as to what valid Enemy types areaccepted. Also, you are not required to choose these specifictypes/values and may create any enemy types you like... be creative2. 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 merged into a single file,you may add the following code to the bottom of your source file toexecute the intended behavior. Note, that you must be sure to usethe same/proper naming conventions as outlined prior to ensureproper 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