QuestionQuestion

Objectives: Learning Inheritance, Superclass and Subclass.

Mission:
1. We'll be creating TWO new objects in this lab, a "Living Being" and a "Fighter"
2. The Living Being object will be the base class where it contains the Health and Attack values (along with their respective functions/methods)
3. Move those information from the monster into the living being, then inherit them back.
4. Fighter will also belong in the living being category, so inherit them too.
5. At the beginning of the program, you will be Creating the Fighter, (optional) ask the user to either randomly generate the fighter's stats or ask the user to allocate the points into each of the fighter's stats.
6. Modify the attack the monster to use fighter's attack stats, also have the monster attack back to the fighter once.

Fighter will have:
• Health (double/float), Level(int), Attacks(int), CurrentExp(int), Defense(int), MaxExp (int)
• Health and Attacks shouldn't be in the fighter object, but rather in the living beings
• When taking damage, minus the damage by the defense and make changes to the fighter’s health
• MaxExp goes by the following function: 40+(Level*10)
• Every time the fighter attacks the monster, he also gains the exp that the monster
• Currently the Level will do nothing.
• If you don't want to auto-generate the fighter's stats, use the following data when you make the Fighter: HP (100), Atk (5), Level (1), CurrentExp (0), Defense (1)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class Fighter extends LivingBeing {

    private int Level;
    private int CurrentExp;
    private int Defence;
    private int MaxExp;

    /**
    * constructor If you don't want to auto-generate the fighter's stats, use
    * the following data when you make the Fighter: HP (100), Atk (5), Level
    * (1), CurrentExp (0), Defense (1)
    *
    * @param name
    */
    public Fighter() {
       // Health and Attacks shouldn't be in the fighter object,
       // but rather in the living beings
       super("Fighter", 100, 5);
       this.Level = 1;
       this.CurrentExp = 0;
       this.Defence = 1;
       setMaxExp();
    }

    /**
    * constructor
    *
    * @param name
    * @param health
    * @param attack
    * @param Level
    * @param CurrentExp
    * @param Defence
    * @param MaxExp
    */
    public Fighter(float health, int attack,
            int Level, int CurrentExp, int Defence, int MaxExp) {
       // Health and Attacks shouldn't be in the fighter object,
       // but rather in the living beings
       super("Fighter", health, attack);
       this.Level = Level;
       this.CurrentExp = CurrentExp;
       this.Defence = Defence;
       setMaxExp();
    }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$14.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats