Question: Write a program that consists of 4 files: Game.java, GameCharacter.java, Wizard.java, Warrior.java and Archer.java The file game.java contains the main method and creates an object

Write a program that consists of 4 files: Game.java, GameCharacter.java, Wizard.java, Warrior.java and Archer.java

The file game.java contains the main method and creates an object of each of the last 3 classes. It also calls the fight method and the toString method of each of the objects.

The GameCharacter class contains all attributes and behaviors that the different subclasses share. These are the name and the health of the character, as well as the fight method. The fight method takes a GameCharacter object as parameter and prints a message on the screen similar to the following: name hits enemyname, doing x amount of damage. Enemyname now has y health left. Name, enemyname, x, and y are of course replaced with actual values. Create the following 3 subclasses:

The Wizard class has a third, unique attribute named Mana (magical energy), which gets depleted when fighting. Override the fight method to reflect the way the wizard fights, see example output.

The Warrior class has a third, unique attribute named Arrows, which gets depleted when fighting.Override the fight method to reflect the way the warrior fights, see example output.

The Archer class has a third, unique attribute named Stamina, which gets depleted when fighting.Override the fight method to reflect the way the archer fights, see example output.

Make sure to create the appropriate constructors, getters, and setters. Also, the toString method should return all 3 of the character's stats. You determine the values of the variables. You may either hardcode them or generate them at random.

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!