Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your class will provide the following constructors; A constructor that creates a character with specified name, profession, health, mans, and levelup. The level will be

Your class will provide the following constructors;

A constructor that creates a character with specified name, profession, health, mans, and levelup. The level will be set to 1 by default, and the experience to 0.

A no-arg constructor that sets all data fields to 0 (for ints), 0.0 (for doubles), and "" (for Strings).

Your class will also provide the following methods;

Mutators and accessors for all data field except levelup

A method named gain Experience(double exp) that adds the parameter value to the current experience of the character. If, as a result, the experience of the character exceeds the levelup threshold, then we call the method gainLevel that is described below.

A method named getProgress() that returns a double value representing, as a percentage, how close the character is to its leveling-up threshold. It is computed as experience / levelup.

A void method named gainievel() that increments the level by I, then rest the experience of O.

A toString() method that returns a String summarizing all of the character's information, based on the value in each of the fields. You are free to format this information as you see fit but make sure it is human-readable :)

You will then add a main method to your class that tests all the features of your class.

To this end, you will create a first RPG object by using the constructor with arguments. The character will have the following characteristics; Name "Mitsuki Saiga", profession "Hero", 1000 health and mana points, needs 5000 experience points to level up.

You will then create another RPG object, using the no-arg constructor, then using the mutators in order to have it feature the following characteristics; Name "Anorak", profession "Magus", 9999 health and 9999 mana points, level 999, needs 1 experience point to level up.

Step by Step Solution

3.47 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

The Output obtained The Code Used public class RPG RPG class The required data members private String name private String profession private int healt... 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

Financial Management For Decision Makers

Authors: Peter Atrill, Paul Hurley

2nd Canadian Edition

138011605, 978-0138011604

More Books

Students also viewed these Programming questions

Question

Calculate the projected NPV.

Answered: 1 week ago