Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write this program in java without any gui. to show fight between aliens and humans, make an array of interface class e.g character [

image text in transcribed

please write this program in java without any gui.

to show fight between aliens and humans, make an array of interface class e.g character [ ]c1=new c1[5];

c1[0]=new Alien();

c1[1]=new Alien();

c1[2]=new Wizard();

c1[3]=new Alien();

c1[4]=new Warrior();

Output

for output call those characters randomly and show output like this

Wizard attacked health 50

Alien attacked health 40

Wizard defended 70 (power gained)

and so on,Please solve this assignment i be grateful.

no one is warrior thats a mistake.warrior will subtract 20 points

Question 1 (40 marks) You are to develop a simple game that allows the user to select their character and interact with the opponent via interface communication. The game will contain characters that have certain functionalities, some of which will be applicable on all characters while some which will be limited to a certain character type. All the characters of the game will be able to jump, defend, and speak. All characters will also maintain a health field that calculates the remaining power of the character after attack. The game will contain two types of characters: Humans and Aliens. The Aliens will be the opponents to the user, and will be able to attack. The Humans characters will have a name, and will be able to explore and attack. Two types of Humans exist in the game: Wizards and Warriors. The Wizards will be able to heal, and attack using fireballs, while the Warriors will be able to capture and attack using swords. All the functions should simply print the action of the character, e.g, Alien defend() should print: "Alien defended the attack". The attack function should subtract the power from the character health as well. Attacks performed by aliens should subtract 5 points, attacks performed by wizards should subtract 15 points and attacks performed by wizards should subtract 20 points. Heal functions should add 10 points to the character health. Keep in mind that the health points should not fall below 0 or exceed 100. Hint: Exception handling. Once the power has reached 0, the user should be notified of this with a message: "Character has been wasted". The power should not be visible to the opponents. Hint: Access modifiers The name of the Human character should only contain letters and numbers. The game should maintain a list of the characters created by the user in the game, and have should no more than 5 active characters at one point. Hint: Exception handling. You have to show the interaction between at least one alien and one human character in your game. Aliens should not be able to harm aliens and humans should not be able to harm humans (Print error: "Cannot attack same character type). Hint: Instanceof You can either use a menu to call the various functions, or initialize the characters in the main method to show interaction

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago