Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE USE THE FOLLOWING HERO CLASS TO COMPLETE THE QUESTION. Your task is to create a GUI application that allows a user to create a

PLEASE USE THE FOLLOWING HERO CLASS TO COMPLETE THE QUESTION.

image text in transcribed

image text in transcribedimage text in transcribed Your task is to create a GUI application that allows a user to create a group of Hero objects. Your group may be a small band of two or three Heroes or it may consist of thousands (think Lord of the Rings or the Marvel Cinematic Universe here).

You have been given the compiled version of the class encapsulating a Hero and you have also been given the specification. Your job is to create a GUI application that allows the user to create an ArrayList of Hero objects. Your GUI should allow the following operations on your Hero list:

? Add Hero objects to the list your list should start out with zero Heroes. You should be able to add Hero objects by reading in from a text file or by adding them individually through the GUI.

? Delete Hero objects from the list you can delete by index number, by hero name or both

? Determine the Hero object with the highest energy level (i.e., the healthiest)

? Cast a spell of heal all that adds a random number of energy points (say between 1 and 50) to all living Heroes.

? Remove all perished (i.e., non?living) Heroes from the list

? Determine the total and average energy points of the entire group of Heroes

? Determine if a particular Hero is in the list search by name

? Write the current Hero list out to a new file

1 package question2; 3@author aaron 4* This class encapsulates a simple hero object 7 public class Hero implements Cloneable private int energy; private String name, heroClass; private String [] backpack; 10 12 13 private int BACKPACK SLOTS 5; 15 16 17 18 *Default no-arg constructor. *Precondition: none Postcondition: nameAnonymous, energy-100, heroClass-warrior, backpack is empty 19 20 21 public Hero) energy = 100; name - "Anonymous" heroClass "warrior"; backpack new String [BACKPACK_SLOTS]; 23 25 26 27 28 29 30 31 32 *3-arg constructor *Precondition: Incoming name is not null and not empty *Precondition: Incoming energy is greater than 0 *Precondition: Incoming heroClass is one of warrior, wizard or ranger Postcondition: All data fields initialized, backpack is empty. 35 36 37 *@param energy - initial energy *@param name - initial name *@param heroClass -initial class *throws IllegalArgumentException if energy is negative. empty warrior, wizard or ranger. 38 *throws IllegalArgumentException if name is null or 39 *throws IllegalArgumentException if class is not 41 public Hero (int energy, String name, String heroclass) 1 package question2; 3@author aaron 4* This class encapsulates a simple hero object 7 public class Hero implements Cloneable private int energy; private String name, heroClass; private String [] backpack; 10 12 13 private int BACKPACK SLOTS 5; 15 16 17 18 *Default no-arg constructor. *Precondition: none Postcondition: nameAnonymous, energy-100, heroClass-warrior, backpack is empty 19 20 21 public Hero) energy = 100; name - "Anonymous" heroClass "warrior"; backpack new String [BACKPACK_SLOTS]; 23 25 26 27 28 29 30 31 32 *3-arg constructor *Precondition: Incoming name is not null and not empty *Precondition: Incoming energy is greater than 0 *Precondition: Incoming heroClass is one of warrior, wizard or ranger Postcondition: All data fields initialized, backpack is empty. 35 36 37 *@param energy - initial energy *@param name - initial name *@param heroClass -initial class *throws IllegalArgumentException if energy is negative. empty warrior, wizard or ranger. 38 *throws IllegalArgumentException if name is null or 39 *throws IllegalArgumentException if class is not 41 public Hero (int energy, String name, String heroclass)

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 Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

5. Develop the succession planning review.

Answered: 1 week ago