Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions