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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started