NEED A PERFECT PAPER? PLACE YOUR FIRST ORDER AND SAVE 15% USING COUPON:

4.8/5

Character's starting health after bonus has been applied

As a junior programmer, your work last week on “Legendary Epics” is earning you some kudos from your fellow coders; however, your overbearing supervisor, Lester Zamboni, wants you to re-write your code from the prior week to make it a little more “efficient, re-usable, and modular.” Here are his directives: You need to write a class definition named Character. In that class definition, you will need these PRIVATE instance variables: A string called charName An integer called startHealth A double called startCurrency Also in that class definition, you will need a setter and a getter method for each instance variable, totaling 6 methods in all: setCharName; getCharName; setHealth; getHealth; setCurrency; getCurrency This class needs to be named Character.java. Your executable class will still need to be called Charactergen.java. You believe that you will still need these variables in your main method: final double BASE_CURRENCY = 10.55; final int BASE_HEALTH = 50; int minHealthBonus = 1; int maxHealthBonus = 5; String cName; In pseudocode, your main method MUST do 5 things: // Create a new character object named human // Use the Character class method to SET the character’s name object data field by prompting the user to enter a character name // Use the Character class method to SET the character’s health object data field by calling the calculateHealth method // Use the Character class method to SET the character’s currency object data field by calling the calculateCurrency method // Call the displayOutput Method by passing the set object data field values of character name, starting health, and starting currency through the Character class GETTER methods In order to be more modular, you decide that you need three additional methods besides the main method: calculateHealth(), which accepts passing BASE_HEALTH, minHealthBonus, and maxHealthBonus as parameters, and performs the calculation as done in last week’s assignment. Remember that starting health is a random number between 50 and 55. calculateCurrency(), which accepts BASE_CURRENCY as a parameter, performs the calculation to generate starting currency, which is always 10.55 minus a random number between 0 and 1. displayOutput(), which accepts the values of character name, starting health, and starting currency as parameters and displays them to the end user in a message dialog box, identical to last week’s assignment. You MUST use the 3 getter methods to get the human object’s data field values.

LAST WEEK ASSIGNMENT :

Don't use plagiarized sources. Get Your Custom Essay on
Character's starting health after bonus has been applied
Just from $13/Page
Order Essay

import javax.swing.JOptionPane;

import java.text.*;

public class Charactergen

{

public static void main(String[] args)

{

String charName;

int minHealthBonus = 1; //Minimun possible amount for starting health bonus

int maxHealthBonus = 5; //Maximun posible amount for starting health bonus

int startingHealth; //Character’s starting health after bonus has been applied

final int BASE_HEALTH = 50; //Initial health

double startingCurrency; //Character’s starting currency after deduction has been made

final double BASE_CURRENCY = 10.55; //Character’s starting currency before deduction is made

DecimalFormat df = new DecimalFormat(“#.##”);

//The following creates a pop up menu prompting the user to enter a character name, the user’s input is stored as a string called charName

charName = JOptionPane.showInputDialog(null, “Enter your character’s name:”, “Welcome to Legendary Epics!”, JOptionPane

.QUESTION_MESSAGE);

//Calculates the character’s starting health.

//A random # between 1-5 is added to the characters base health. Health cannot be less than 51 or higher than 55

startingHealth = BASE_HEALTH + (minHealthBonus + (int)(Math.random() * maxHealthBonus));

//Calculates the character’s starting amount of currency

//A random number between 0 and 1 is subtracted from the character’s base currency. Currency will start at no less than 9.55 or higher than 10.55

startingCurrency = BASE_CURRENCY – (Math.random());

//The following creates a pop up menu displaying the name the user entered and also the character’s starting health and currency amounts

JOptionPane.showMessageDialog(null, “Your name is ” + charName + “, your starting health is ” + startingHealth + ” and your starting credits are ” + (Double.valueOf(df.format(startingCurrency))), “Your Character Stats”, JOptionPane.INFORMATION_MESSAGE);

Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!
Open chat
Scan the code
Need help with this or a different assignment? We offer CONFIDENTIAL, ORIGINAL (Turnitin/LopesWrite/SafeAssign checks), and PRIVATE services using latest (within 5 years) peer-reviewed articles. Kindly click on ORDER NOW to receive an A++ paper from our masters- and doctorate-prepared writers.