Question: RPG Player class Design and implement a RPG ( role - playing game ) Player class. Players should be able to battle with each other.
RPG Player class Design and implement a RPGroleplaying game Player class. Players should be able to battle with each other. The Player class should include the following instance variables: name: players name status: in this game we will only have types of status: alive and dead experience: The experience points often abbreviated as exp or XP is a unit of measurement used to quantify a player character's life experience and progression through the game. In our design each battle the player fights will earn them experience points. level: A level is a number that represents the overall power of the player and is determined by the players experience points. The more experience points the player has the higher level the player will be in The level of the player decides the value of max hit points and damage points. currentHitPoints: The current hit points indicate how much damage the player can take before they die. If the value drops to the player is dead. maxHitPoints: This is the ceiling of your current hit points. Lets say you have hit points out of a maximum of and you drink a potion and recover hit points. Your hit points cap out at meaning you have one healing power wasted. This is just an example. We will not have healing implemented in this program. damagePoints: Damage points reflect the amount of harm inflicted on a player by an opponent's attack. Damage points of the opponent are deducted from the current hit points and vice versa the damage points the current player has will be deducted from the opponents current hit points. The Player class should include the following methods: getters and setters: Some setters can be tricky. For example, when the value of experience is set, it should also set the level, which should set the value of maxHitPoints and demagePoints. When the currentHitPoints is set it should also set the status of the player. If below the player is dead. The currentHitPoints should never exceed the maxHitPoints of the player, which is determined by the players level. Algorithm to use in the setters: level experience level : ; level : Use an if statement to set the level to if the level is below maxHitPoints intlevellevel damagePoints level constructor: One constructor that takes name, experience, and currentHitPoints as parameters. public PlayerString name, int experience, int currentHitPoints toString: The toString method should return all the info about the player. battle: The method should have a Player typed parameter. For example: Public void battlePlayer player During the battle each player will have their current hit points deducted by the number of the damage points the opponent has. After the battle each player will gain experience points. Use the following main method to test your class. Feel free to change the players name but DO NOT change the initial passedin experience and currentHitPoints in the example. public static void mainString argsfeel free to change the players names, but do not change anything else Player player new PlayerFiFi; Player player new PlayerMoblin; System.out.printlnbefore the battle:"; System.out.printlnplayer; System.out.printlnplayer; System.out.printlnplayergetName is battling playergetName; playerbattleplayer; System.out.printlnafter the battle"; System.out.printlnplayer; System.out.printlnplayer; System.out.printlnbattle again"; playerbattleplayer; System.out.printlnafter the battle"; System.out.printlnplayer; System.out.printlnplayer; Run your program and insert the results in the appropriate section of the machine problem worksheet.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
