Objectives To use inheritance To understand polymorphism Introduction For this program, you will use a random...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objectives To use inheritance To understand polymorphism Introduction For this program, you will use a random number generator to determine what enemy type will be created and stored in an ArrayList. This program could be used as a subcomponent of a computer game. Instructions and Information You must create a general abstract Enemy class with the following fields: weight (an integer) height (an integer) The Enemy class must also have the following methods: Getters for both the weight and height Setters for both the weight and height In addition to the Enemy class, you should have four different concrete (non-abstract) classes that extend the Enemy class: Goblin Ghost A constructor that takes the weight and the height An abstract method, attack, that (when implemented) will simply print out (using System.out methods) the specific attack of the subclass type Ogre Weight should be generated randomly between 5 and 10 Height should be generated randomly between 70 and 100 The attack method should print "Gurgle!" Weight should be o Height should be generated randomly between go and 150 The attack method should print "Boo!" Weight should be generated randomly between 120 and 200 Height should be generated randomly between 200 and 300 The attack method should print "Ugh!" Dragon Your program should create an ArrayList capable of holding any kind of Enemy. Then, you should generate 100 different enemies using random number generators (RNGs) to select a particular enemy, and also to set their specifications (e.g., weight and height) when necessary. Weight should be generated randomly between 1000 and 1500 Height should be generated randomly between 750 and 2000 The attack method should print "Rawr!" If the RNG returns a 1, then create a Goblin and add it to the ArrayList. If the RNG returns a 2, create a Ghost. If it returns a 3, create an Ogre, and if it returns a 4, create a Dragon. Thus, the number used from the RNG should ultimately fall between 1 and 4 (inclusive) - which can be done using appropriate scaling and shifting of the values returned by the RNG. Add each of the 100 enemies to the ArrayList, and then loop through the array list and print out the attacks from each of the enemies in the array list. So output might look something like: Boo! Gurgle! Gurgle! Gurgle! Rawr! Ugh! Rawr! Rawr! Ugh! Deliverables To turn in the assignment, please upload a zip file of a folder containing: The .java files necessary for the program to run. O Upload them to the appropriate assignment directory in Assignments on D2L. Screenshots of your program running Everything should be in a single zip file when submitted Objectives To use inheritance To understand polymorphism Introduction For this program, you will use a random number generator to determine what enemy type will be created and stored in an ArrayList. This program could be used as a subcomponent of a computer game. Instructions and Information You must create a general abstract Enemy class with the following fields: weight (an integer) height (an integer) The Enemy class must also have the following methods: Getters for both the weight and height Setters for both the weight and height In addition to the Enemy class, you should have four different concrete (non-abstract) classes that extend the Enemy class: Goblin Ghost A constructor that takes the weight and the height An abstract method, attack, that (when implemented) will simply print out (using System.out methods) the specific attack of the subclass type Ogre Weight should be generated randomly between 5 and 10 Height should be generated randomly between 70 and 100 The attack method should print "Gurgle!" Weight should be o Height should be generated randomly between go and 150 The attack method should print "Boo!" Weight should be generated randomly between 120 and 200 Height should be generated randomly between 200 and 300 The attack method should print "Ugh!" Dragon Your program should create an ArrayList capable of holding any kind of Enemy. Then, you should generate 100 different enemies using random number generators (RNGs) to select a particular enemy, and also to set their specifications (e.g., weight and height) when necessary. Weight should be generated randomly between 1000 and 1500 Height should be generated randomly between 750 and 2000 The attack method should print "Rawr!" If the RNG returns a 1, then create a Goblin and add it to the ArrayList. If the RNG returns a 2, create a Ghost. If it returns a 3, create an Ogre, and if it returns a 4, create a Dragon. Thus, the number used from the RNG should ultimately fall between 1 and 4 (inclusive) - which can be done using appropriate scaling and shifting of the values returned by the RNG. Add each of the 100 enemies to the ArrayList, and then loop through the array list and print out the attacks from each of the enemies in the array list. So output might look something like: Boo! Gurgle! Gurgle! Gurgle! Rawr! Ugh! Rawr! Rawr! Ugh! Deliverables To turn in the assignment, please upload a zip file of a folder containing: The .java files necessary for the program to run. O Upload them to the appropriate assignment directory in Assignments on D2L. Screenshots of your program running Everything should be in a single zip file when submitted
Expert Answer:
Answer rating: 100% (QA)
The simple Java program that fulfills the requirements described in your question This program uses inheritance polymorphism and a random number gener... View the full answer
Related Book For
Applied Statistics From Bivariate Through Multivariate Techniques
ISBN: 9781412991346
2nd Edition
Authors: Rebecca M. Warner
Posted Date:
Students also viewed these programming questions
-
for the equality test for M and N. The question concerns how to represent multisets of strings within ML. For each of the given data representations (a), (b) and (c) describe how you would implement...
-
123 Compare the purely graphical properties of these two notations, and the ways in which the graphical properties of each display correspond to the information structure being defined. Describe...
-
An orange grower in Florida faces a dilemma. The weather forecast is for cold weather, and there is a 50% chance that the temperature tonight will be cold enough to freeze and destroy his entire...
-
In a nuclear reactor, neutrons released by nuclear fission must be slowed down before they can trigger additional reactions in other nuclei. To see what sort of material is most effective in slowing...
-
In FIGURE EX28.30, what is the value of the potential at points a and b? FIGURE EX28.30:
-
Match the measures of worth in the first column with the appropriate unit of measure that results from the analysis. Measure of Worth (a) Annual Worth (b) External Rate of Return (c) Future Worth (d)...
-
Alena Co. was organized on July 1, 2017. Quarterly financial statements are prepared. The unadjusted and adjusted trial balances as of September 30 are shown below. Instructions (a) Journalize the...
-
What is relational algebra? b) What are the types of relational algebra? Question No. 02 a) What is Data definition language (DDL)? b) What is Data manipulation language (DML)? Question No. 03 a)...
-
Can someone please summarize the case study below: if you know about the case IKEA Looks to Further Penetrate the U.S. Market 10 CASE Synopsis: IKEA is known around the world for its stylish,...
-
Of the four imperatives discussed in this chapter economic, political, quality, and administration which would be most important to IBM in its efforts to make inroads in the Pacific Rim market?...
-
How does method overriding contribute to the polymorphic behavior in Java, elucidating its significance in object-oriented programming paradigms? Explain
-
Prove that NOR can build, : AND,OR , and NOT with Examples
-
In the small country of Fictionia, there are 30 workers. Each worker can produce 4 shirts in one day, or bake 1 loaf of bread. These are the only two goods the can be produced. Part A) Draw the...
-
Finance Problems 1) What is the initial outlay, given the following information: Equipment Price. $375,000 Installation. 10,000 Power Survey 30,000 Shipping. 8,000 Working Capital 100,000 Project...
-
On 2 January 2016, ME Ltd (ME) issued $10,000,000 5-year bonds for $10,811,090. The stated coupon rate is 10% per annum, and the effective interest rate is 8% per annum. Interest is to be paid...
-
Discuss the difficulties in welding a material A with A-7.86 g/cm3 & specific heat capacity Cp/A 640.80 J/(molK) and material B with specific heat capacity Cp/B 25.20 J/(molK) and B = (1/3)(A)...
-
Should we separate the debt and equity features of convertible debt? Team 1: Pro separation: Present arguments in favor of separating the debt and equity features of convertible debt. Team 2: Against...
-
For a regression (to predict Y from X1 and X2), is it possible to have a significant R, but non significant b coefficients for both X1 and X2? If so, under what circumstances would this be likely to...
-
How can we identify disproportionately influential scores and/or multivariate outliers?
-
How is a t distribution similar to a standard normal distribution score? How is it different?
-
On November 15, 20X3, Chow Inc., a U.S. company, ordered merchandise FOB shipping point from a German company for 200,000. The merchandise was shipped and invoiced on December 10, 20X3. Chow paid the...
-
On April 8, 20X3, Trul Corporation purchased merchandise from an unaffiliated foreign company for 10,000 units of the foreign companys local currency. Trul paid the bill in full on March 1, 20X4,...
-
On September 1, 20X1, Cott Corporation received an order for equipment from a foreign customer for 300,000 LCUs when the U.S. dollar equivalent was $96,000. Cott shipped the equipment on October 15,...
Study smarter with the SolutionInn App