Question: Write a well-modularized program for two creatures to battle. creature class manages one creature only . member variables to store . strength (a measure
Write a well-modularized program for two creatures to battle. creature class manages one creature only . member variables to store . strength (a measure of how physically strong a character is) health (determines the maximum amount of damage that a character or object can take; sometimes referred to as name constructors default 4- argument constructor to set all member variables; call setCreature() function to avoid redundancy . mutator function to . type possible types are demon, elf, balrog use enum; e.g. creatureType {BALROG, ELF); (about enums) .setCreature function to set all member variables; no validation is needed accessor functions to return health strength .name with the type should return the name and the type of a creature, e.g. "Langdon the elf " damage (all creatures inflict damage, which is a random number up to their strength damage (rand() % strength) + 1; accessor function to return a creature object as a string (to_String(), for example, "Langdon the elf 10 87" Army class . manages a group of creatures, two for now members two objects of Creature class type of a creature should be randomly generated . let the user name the creatures . set the strength and health of each creature to random values between 25-150 write all necessary constructor(s) add any member functions you see fit main menu, implemented using switch and enum, with options to battle strength of a creature does not change, it is the maximum damage a creature can inflict randomly select which Creature attacks first rules of engagement . turn-based battle creature A attacks creature B, in the next round, creature B attacks creature A, then creature A attacks creature B again, and so on . a health of a defender is reduced by the amount of damage an attacker has inflicted. For example, creature A, the attacker in the current round, attacked with damage of 20; defender's health is 50 (70-20) Go to Settings to activate Windows. . . the battle continues until one of the Creture's health becomes equal to zero . looser: the one whose health becomes equal to zero . winner: the other creature . randomly select who gets to attack first detailed output: who is attacking, and what's the damage, the defender's health after the attack, a winner etc... announce the winner . reset Cretures to prepare for another round use enum for menu implementation . may only use packages discussed in class Activate Windows Go to Settings to activate! for now, you do not have to create separate files for each class in your program; you can put all your classes in the file with Main; put all other classes below Main Tips To generate random numbers, import java.util.Random Random rand= new Random(): // create instance of Random class int rand_int1 = rand.nextInt(1000); // Generate random integers in range 0 to 999 int rand_int2 = rand.nextInt(1000);
Step by Step Solution
There are 3 Steps involved in it
These changes address the feedback provided improving code readability preventing potential issues and following best practices import javautil Random ... View full answer
Get step-by-step solutions from verified subject matter experts
