Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:25:55+00:00 2026-05-29T10:25:55+00:00

I have a homework problem where I have to make an inheritance program that

  • 0

I have a homework problem where I have to make an inheritance program that consists of a class called dungeonCharacter, with two child classes Hero and Monster, that have 3 of their own subclasses that have certain differences, etc etc. I am having trouble with the main class dungeonCharacter. here is the description:

DungeonCharacter (base - abstract)
contains instance variables that any character in the game will have -- protected access     is ok (NO public access allowed!) 
o name - String
o hit points (how much damage a character can take before it expires) - integer
o attack speed - integer (1 is slowest)
o damage range (minimum and maximum amount of damage a character can do on an 
attack) - two integers
o chance to hit opponent when attacking - double
o anything else you deem necessary
 constructor to initialize instance variables get and set methods as you deem necessary
 an attack method 
o first checks if character can attack (based on chance to hit)
o if it can, a hit in range of minimum to maximum damage is generated and applied to 
opponent -- user should be informed of what happens
o if it cannot, a message should be displayed that says the attack failed

here is my code, i am having a hard time really understanding a few things, in particular, the attack method, and the chance of hitting. I dont know how to get started on that and where to go from here. here is my code so far.

public abstract class DungeonCharacter {
    protected String name;
    protected int hitPoints;
    protected int speed;
    protected int minRange;
    protected int maxRange;
    protected double chance;

    public DungeonCharacter(String name, int hitPoints, int speed,
int minRange, int maxRange, int chance) {
        this.name = name;
        this.hitPoints = hitPoints;
        this.speed = speed;
        this.minRange = minRange;
        this.maxRange = maxRange;
        this.chance = chance;
    }

    public void setString(String newName) {
        name = newName;
    }

    public String getName() {
        return name;
    }

    public void Attack() {

    }
}

please help me understand this and find the necessary code to fulfill the directions, this hwk is very vague in my opinion and Im having a hard time understanding. and the teacher is useless. thanks for helping! if i can just get this written writing the rest should be easy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:25:56+00:00Added an answer on May 29, 2026 at 10:25 am

    In the absence of any hard data, make up your own criteria. As long as its reasonable, and you can justify it on questioning, you should be all set. The fact that the variable is called “chance” to apply damage, indicates to me the presence of a probability distribution, which means that 0.0 means no chance of hitting, and 1.0 means that you can absolutely hit. You can think about it in terms of 0.0 probably means that the character is too far away to damage the enemy. 1.0 means you’re standing right in front of the enemy. The amount of damage that you could apply on attack would therefore depend on the chance to attack and the minimum / maximum damage that can be dished out.

    public void attack() {
        if(chance > 0.0 /* Some arbitrary value */) {
            double damageToApply = minRange + chance*(maxRange - minRange);
            System.out.println("Applying damage: " + damageToApply);
        } else {
            System.out.println("Unable to apply damage, flee!");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with classes. I made my own class called Person. Which
I have done a homework assignment, here is the problem statement: Your program should
I have a program that solves the weighted interval scheduling problem using dynamic programming
Note: This is a homework assignment. I have two classes, one inherits from the
This is a homework problem that I have. I have been doing some research
I have big problem because i dont uderstand properly how make my homework. Well
It seems that I have to make it in detail; it's my homework. I
I have a homework assignment to make a simple program in assembly language for
I have a homework problem for my algorithms class asking me to calculate the
Okay, so I have another question on a prolog homework problem I am struggling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.