Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class RtKnight { // these variables track the information in the knight object private final int maxHealth; private String name; private int power; private

public class RtKnight {

// these variables track the information in the knight object private final int maxHealth; private String name; private int power; private int armor; private int damage = 0; private int xp = 0;

/** * Gets the experience points for the knight * @return amount of XP */ public int getXp() { return 0; //TODO Student }

/** * Sets the experience points. Complete set, not adding to the current pool. * @param xp amount to set XP to. */ public void setXp(int xp) { //TODO Student }

/** * Gets the name of the knight * @return the name of the knight */ public String getName() { return null;//TODO Student }

/** * Sets the name of the knight * @param name the name to set for the knight */ public void setName(String name) { //TODO Student }

/** * Gets the maxHealth for the knight. Max doesn't change at this point * @return the health of the knight */ public int getMaxHealth() { return 0; //TODO Student }

/** * Gets the maxHealth minus the amount of damage taken * @return int value of health-damage */ public int getRemainingHealth() { return 0; //TODO Student }

/** * Adds to the total damage counter * @param amount the amount to add to the damage counter */ public void addDamage(int amount) { //TODO Student }

/** * Resets the knight after a battle. At this point, resets damage taken to zero. */ public void reset() { //TODO Student }

/** * Gets the knight's power level * @return the power of the knight */ public int getPower() { return 0; //TODO Student }

/** * Sets the knights power * @param power the value to set the power to */ public void setPower(int power) { //TODO Student }

/** * Gets the knights amount of armor * @return the armor score */ public int getArmor() { return 0; //TODO Student }

/** * Sets the knights armor score * @param armor value to set armor to */ public void setArmor(int armor) { //TODO Student }

/** * Gets a contact card for the knight. Example cards look like * +============================+ * | Pendragon | * | | * | Health: 100 XP: 0 | * | Power: 100 Armor: 100 | * | | * +============================+ * * and * +============================+ * | Bedwyr Bedrydant | * | | * | Health: 75 XP: 0 | * | Power: 100 Armor: 15 | * | | * +============================+ * * Width and spacing remains no matter the length of the knights name and score values. * * Each line in the card is 30 characters long , and for the spacing * String.format is used with the space parameter. For example: * String.format(| %-27s|%n", getName()) * * @return a completed card of six lines */ public String getCard() { //TODO Student return null; }

// -------------- don't edit below this line ---------------

/** * toString helps with debugging, as we can print the knight info directly * @return the string representing the knight */ public String toString() { return String.format("[name = %s, health = %d, power = %d, armor = %d, damage = %d, xp = %d]", name, maxHealth, power, armor, damage, xp); }

/** * Constructor for the knight * @param name name of the knight * @param maxHealth maxHealth of the knight * @param power the power of the knight * @param armor the armor of the knight */ public RtKnight(String name, int maxHealth, int power, int armor) { setName(name); this.maxHealth = maxHealth; // this doesn't have a setter so we use that setPower(power); setArmor(armor); }

}

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions