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.
P.S I can't make the main file Game.java correct. Please help me to write the main file first. I took care of the rest.
Sample output should be like this:
Player1 shoots casts a magic spell at Player2, doing 8 damage. Player 2 has now 92 health left.
Player2 hits Player3 with his sword, doing 8 damage. Player 3 has now 92 health left.
Player3 shoots an arrow at Player1, doing 8 damage. Player 1 has now 92 health left.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
