Write a well-modularized program for two creatures to battle. creature class manages one creature only...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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); 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);
Expert Answer:
Answer rating: 100% (QA)
These changes address the feedback provided improving code readability preventing potential issues and following best practices import javautil Random ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Barry buys 100 shares of MSFT stock on April 1, 2008, for $50,000. On June 1, 2009, he sells all 100 shares for $70,000. Barry earns $150,000 per year. At what rate, if any, is this gain taxed?...
-
In this programming assignment you will practice using ArrayLists, Inheritance and Polymorphism. You are to write a game called Magical Creatures War. You will do this by implementing a class called...
-
advice on how healthcare leaders can move their organizations toward being an HRO?
-
Determine the resultant moment of the two forces about the Oa axis. Express the result as a Cartesian vector. Given: F1 = 80 lb F2 = 50 lb α = 120 deg β = 60 deg γ = 45 deg a = 5 ft...
-
John is putting money into a checking account. Let y represent the total amount of money in the account (in dollars). Let x represent the number of weeks John has been adding money. Suppose that x...
-
What is the major advantage of snowball sampling?
-
Michelle Gutierrez, manager of the Components Division of FX Corporation, is considering a new investment for her division. The division has an investment base of $4,000,000 and operating income of...
-
Situation: A surf shop called Crazy Wave has seen sales drop after the euphoria of its opening. Since its inception, the owner has invested about $5,000 a month in traditional advertising (magazines,...
-
Prepare a Consolidated Balance Sheet for Big Lake Bakeries which owns 100% of Marble Falls Orchards. The fair value of Marble Falls net fixed assets are $2,675,000. Big Lake aquired 100% of Marble...
-
What is the profitability index of a project that costs $8,000 and provides cash flows of $2,600 in years 1 and 2 and $4,600 in years 3 and 4? The discount rate is 8%.
-
A Viennese travel agency offers 76 different packages for seaside getaways across Greece, Spain, Italy, and Croatia. An analyst engaged in the tourism industry wants to analyse the factors...
-
In 20X2 Franklin Fibres Business had net cash provided by operating activities of \(\$ 9400\). A review of its \(20 \mathrm{X} 2\) financial statements shows that the business had net income of \(\$...
-
Answer the following questions regarding choosing an appropriate model: a. What is the first step in choosing which model fits the data best? b. If you cannot decide on using the above step, what...
-
Burden PLC has an authorised capital of 500,000 ordinary shares of 0.50 each. (a) At the end of its financial year, 31 May 2016, the following balances appeared in the company's books: The company's...
-
Dinho and Manueli are in partnership sharing profits and losses equally after interest of 10% on each partner's capital account in excess of 100,000. At 31 December 2015, the partnership trial...
-
On average, weight of carry-on baggage of passengers on planesis 32.2 pounds. Assuming a standard deviation off 4.3 pounds, findthe probability that the average weight of carry-on baggage of arandom...
-
On July 1, 2011, Flashlight Corporation sold equipment it had recently purchased to an unaffiliated company for $480,000. The equipment had a book value on Flashlights books of $390,000 and a...
-
Bill Barriers, CEO of MightySoft software, is contemplating a new marketing strategy: bundling their best-selling wordprocessor and their spreadsheet together and selling the pair of software...
-
If you think Edmund is odd, consider his brother Emmett. Emmett consumes speeches by politicians and university administrators. He is paid $1 per hour for listening to politicians and $2 per hour for...
-
Jim and Tammy are partners in Business and in Life. As is all too common in this imperfect world, each has a little habit that annoys the other. Jims habit, we will call activity X, and Tammys habit,...
-
Approximately 50,000 new titles, including new editions, are published each year in the United States, giving rise to a $25 billion industry in 2001. In terms of percentage of sales, this industry...
-
When you think of political persuasion, you may think of the effortsthat political campaigns undertake to persuade you that their candidate is betterthan the other candidate. In truth, campaigns are...
-
In late 2013, the taxi company Yourcabs.com in Bangalore, India, was facing a problem with the drivers using their platformnot all drivers were showing up for their scheduled calls. Drivers would...
Study smarter with the SolutionInn App