Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do it in Java: Copy your character classes from called project3.characters. Create an array of several (at least 4) game characters of different types.

Please do it in Java:

  1. Copy your character classes from called project3.characters.
  2. Create an array of several (at least 4) game characters of different types.
  3. Write a driver class that simulates a Battle Royale between the characters in the array. In a loop, select an attacker at random from the array and have them attack a random character. Continue until only one character remains. Print out the name of the winner

Character Classes:

//Character.java package project3.characters; public abstract class Character { /** * The Name. */ protected String name; /** * The Strength. */ protected int strength; /** * The Health. */ protected int health; /** * Instantiates a new Character. * * @param name the name */ public Character(String name) { this.name = name; } /** * Gets name. * @return the name */ public String getName() { return name; } /** * Gets strength. * @return the strength */ public int getStrength() { return strength; } /** * Gets health. * @return the health */ public int getHealth() { return health; } /** * Attack int. * @return the int */ public abstract int attack(); /** * Hit. * * @param points the points */ public abstract void hit(int points); /** * Is alive boolean. * @return the boolean */ public abstract boolean isAlive(); @Override public String toString() { return "Name: " + name + ", Strength: " + strength + ", Health: " + health ; } } 

//=>Hulk.java

//Hulk.java package project3.characters; public class Hulk extends Character { public Hulk(String name) { super(name); this.health = 100; this.strength = 10; } @Override public int attack() { return strength; } @Override public void hit(int points) { this.health -= points; } @Override public boolean isAlive() { return health>=0; } @Override public String toString() { return "[ Class: Hulk, "+super.toString()+" ]"; } } 

//=>Monster.java

package project3.characters; public class Monster extends Character { public Monster(String name) { super(name); this.health = 100; this.strength = 5; } @Override public int attack() { return strength; } @Override public void hit(int points) { this.health -= points; } @Override public boolean isAlive() { return health>=0; } @Override public String toString() { return "[ Class: Monster, "+super.toString()+" ]"; } } 

//=>Venom.java

package project3.characters; public class Venom extends Character { public Venom(String name) { super(name); this.health = 100; this.strength = 15; // more powerful to attack } @Override public int attack() { return strength; } @Override public void hit(int points) { this.health -= points; } @Override public boolean isAlive() { return health >= 0; } @Override public String toString() { return "[ Class: Venom, "+super.toString()+" ]"; } }

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

More Books

Students also viewed these Databases questions

Question

give the soultlution to it

Answered: 1 week ago

Question

Question May I set up a Keogh plan in addition to an IRA?

Answered: 1 week ago