Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Player {
- private String userName;
- private int healthLevel;
- private int currentHealth;
- private int miningLevel;
- private int miningLevelXP;
- // Setting Player Constructor
- public Player(String userName) {
- this.userName = userName;
- healthLevel = 10;
- currentHealth = healthLevel;
- miningLevel = 1;
- miningLevelXP = 0;
- }
- // Getting Player Username and Printing It Out.
- public void getPlayerUsername() {
- System.out.println("Username: " + this.userName);
- }
- // Getting Player Health and Printing It Out.
- public void getPlayerHealth() {
- System.out.println("Health Points: " + this.currentHealth + "/" + this.healthLevel);
- }
- // Getting Players Mining XP and Printing It Out.
- public void getPlayerMiningXP() {
- System.out.println("Mining XP: " + miningLevelXP);
- }
- // Returning The Integer of The Players Mining Level.
- public void getPlayerMiningLevel() {
- System.out.println("Mining Level: " + miningLevel);
- }
- // Returning The Integer of The Players Mining Experience.
- public int getPlayerMiningEXP() {
- return miningLevelXP;
- }
- // Player Action Methods
- // Player Eat Action To Restore Health Points.
- public void eat(int foodHP, String foodName) {
- System.out.println("You ate some " + foodName + ", it healed you for " + foodHP + " health points ");
- currentHealth += foodHP;
- if (currentHealth >= healthLevel) {
- currentHealth = healthLevel;
- }
- }
- // Player Take Damage Action To Reduce Health Points.
- public void takeDamange(int damangeHP) {
- System.out.println("You've taken damage, you have lost " + damangeHP + " health");
- currentHealth -= damangeHP;
- }
- // Method To Calculate The Players Mining Level
- // Based Off of The Players Mining Experience.
- public int getPlayerMiningLEVEL() {
- if (miningLevelXP > 0 & miningLevelXP < 5) {
- miningLevel = 1;
- } else if (miningLevelXP >= 5 & miningLevelXP < 10) {
- miningLevel = 2;
- } else if (miningLevelXP >= 10 & miningLevelXP < 15) {
- miningLevel = 3;
- } else if (miningLevelXP >= 15 & miningLevelXP < 20) {
- miningLevel = 4;
- } else if (miningLevelXP >=20 & miningLevelXP < 25) {
- miningLevel = 5;
- } else if (miningLevelXP >= 25 & miningLevelXP < 30) {
- miningLevel = 6;
- } else {
- miningLevel = 6;
- }
- return miningLevel;
- }
- // Player Mine Ore Action To Gain Mining Experience and
- // To Check if Mining Level is High Enough To Mine Certain Ore.
- public void mineOre(String oreName, int oreLevel, int oreXP) {
- if (miningLevel >= oreLevel) {
- System.out.println("\nYou mined a " + oreName + " ore and gained " + oreXP + " experience");
- miningLevelXP += oreXP;
- getPlayerMiningXP();
- getPlayerMiningLEVEL();
- } else if (miningLevel < oreLevel) {
- System.out.println("\nYou do not have a high enough mining level to mine " + oreName + " ore.");
- System.out.println("You need a required level of: " + oreLevel);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement