Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Perform using JAVA Consider an inheritance hierarchy: Warrior, Swordsman and Axeman. Warrior is the parent and Swordsman and Axeman are their children. Warrior provides them

Perform using JAVA

image text in transcribed

Consider an inheritance hierarchy: Warrior, Swordsman and Axeman. Warrior is the parent and Swordsman and Axeman are their children. Warrior provides them the variables Attack (int), Defense (int) and Health (int). Moreover, it passes two methods: attack() and defend(). Swordsman changes the definition of attack() by printing out "The swordsman tries to slash the enemy!" while the Axeman defines it by printing: "Axeman says: "Charge!!!! Swordsman changes the definition of defend() by printing out "The swordsman tries to parry!", while the Axeman defines it by printing: "I will block it with my axe!" In main, create a swordsman and an axeman. Provide them their variables through user input. Handle exceptions (for input mismatch). Then in your application try to let the swordsman attack and axeman defend. The application output should look like: Swordsman: Attack Rate: 10, Defense Rate: 5, Health: 100 Axeman: Attack Rate: 15, Defense Rate: 3, Health: 110 The swordsman tries to slash the enemy! I will block it with my axe

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_2

Step: 3

blur-text-image_3

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Can his EI be developed and enhanced?

Answered: 1 week ago