Question: PLEASE WRITE THIS CODE WITH JAVA!!!! Consider a system with a number of different types of Warriors. In your system, Warrior will be a superclass,
PLEASE WRITE THIS CODE WITH JAVA!!!!
Consider a system with a number of different types of Warriors. In your system, Warrior will be a superclass, while Viking and Janissary are subclasses.
Warrior class contains certain fields, such as 'health', 'attack_rate' and 'defense_rate' for the warriors. Also, Warrior provides attack() and defend() functionalities that the subclasses will utilize.
Viking and Janissary override 'attack' and 'defend' methods and define how they eat or move. You can consider printing some relevant statements in each method.
In your main, create an ArrayList of Warriors that you use to assign a janissary and two vikings in. Receive their data through a Scanner from the user. Make sure you handle exceptions regarding possible input mismatch. After this use a foreach loop to print the warrior information and make them attack and defend.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
