Question: Create a JAVA program that will: Use inheritance Operates with polymorphism Use a random number generator to determine what enemy type will be created and

Create a JAVA program that will:

Use inheritance

Operates with polymorphism

Use a random number generator to determine what enemy type will be created and stored in an ArrayList.

For this program, you will 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

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.

In addition to the Enemy class, you should have four different concrete (non-abstract) classes that extend the Enemy class:

Daemon

o Weight should be generated randomly between 20 and 40

o Height should be generated randomly between 100 and 300

o The attack method should print Blahh!

Goon

o Weight should be 0

o Height should be generated randomly between 30 and 75

o The attack method should print Waaaahhh!

Wolf

o Weight should be generated randomly between 30 and 88

o Height should be generated randomly between 100 and 150

o The attack method should print Hayahh!

Monster

o Weight should be generated randomly between 2000 and 3500

o Height should be generated randomly between 220 and 400

o The attack method should print Arrrr!

The program should create an ArrayList capable of holding any kind of Enemy that is listed. It must be able to generate 100 different enemies using random number generators (RNGs) to select an enemy, and be able to set their specifications (e.g., weight and height) when necessary.

If the RNG returns a 1, then create a Daemon and add it to the ArrayList. If the RNG returns a 2, create a Goon. If it returns a 3, create an Wolf, and if it returns a 4, create a Monster.

According to that, the number used from the RNG should ultimately fall between 1 and 4 (inclusive) which can be scaled appropriatly by 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.

Example output:

Waaaahhh!

Arrrr!

Waaaahhh!

Waaaahhh!

Arrrr!

Hayahh!

Blahh!

Hayahh!

Hayahh!

etc......

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!