Write a client program that creates some


Inheritance

You use your code from Homework 2 to release your game, Super Happy Fun Cute Creatures World Traveler, to widespread acclaim. Unfortunately, within only a few months of release your player base is getting restless! They are easily bored and are demanding that you add more depth to the game.

In response, you decide to introduce a new breed of CuteCreatures into your game world. These creatures will automatically "evolve" once they reach level 20. (Not every creature can evolve - some will stay in their original form no matter how high they level.) Evolved creatures are similar to regular creatures, but they gain the following extras:

• When the creature evolves, it gains a one-time bonus of 15 maximum and current hit points and 5 attackdamage. This is on top of the regular gains fromleveling.

• Each evolved creature becomes "attuned" to a particular element. This is done based on the first letter of the creature'sspecies:
o A-G creatures attune tofire
o H-M creatures attune towater
o N-S creatures attune toair
o T-Z creatures attune toearth

• Evolved creatures gain the ability to perform a special "elemental attack" in addition to their regular attack. This elemental attack is guaranteed never to miss, but it will never score a critical hit either. Additionally, there isno20% variance in the attack damage like there is with the regular attack. The damage done by an elemental attack depends on the element of the target creature:

o If the target creature is of the same element as the attacking creature, the elemental attack deals zero damage.
o If the target creature's element resists the attacking creature's element, the elemental attack deals 0.25x normal attackdamage.
o If the target creature's element is vulnerable to the attacking creature's element, the elemental attack deals 4x normal attackdamage.
o In all other cases, the elemental attack deals the attacking creature's normal attack damage.Thisincludessituations in which an evolved creature performs an elemental attack vs. a creature with no element (which could be an EvolvableCuteCreature who hasn't evolved yet, or just a regularCuteCreature).

The table below summarizes the effects of elemental attacks.

1. Write a subclass EvolvableCuteCreature that extends CuteCreature with the functionality described above. Here are a few guidelines for thissubclass:

• Remember that constructors are not inherited, so you'll need to provide one for theEvolvableCuteCreature
class. Use super to save yourself some coding if possible!

• Include an extra instance variable to indicate which element the creature is attunedto.

• Add a new elementalAttack(CuteCreature c) method. If an EvolvableCuteCreature tries to call this method without having evolved yet, display an appropriate errormessage.

• Override the levelUp() method from CuteCreature to handle the evolution process at level 20. (You should redeclare levelUp() as protected rather thanprivate.)

• Override the toString() method to include which element the creature is attunedto.

2. Write a client program that creates some EvolvableCuteCreature objects and tests your methods. You should especially focus on testing elementalAttack, since there are many different possible outcomes with that move!

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a client program that creates some
Reference No:- TGS02399985

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)