title: Using a player's stats in multiple different classes
body: <p>I'm making a text adventure RPG game, where you can enter a battle, and follow a semi open world story. I made a player class, which I use to hold all of the player's stats.</p>
  
  <pre><code>public class Player {
  
      // Generic Stats
      int playerLevel = 1;
      int playerHealth = 20;
      int EXP = 0;
      long money = 0;
      String name = "";
      String homeland = "";
  
      // Skills
      int fighting = 5;
      int block = 5;
      int doctor = 5;
      int speech = 5;
  
      // Attributes
      int damage = fighting * 2;
  
      // Prints the player's stats
      public void printStats() {          
          System.out.println();
          System.out.println("Level: " + playerLevel);
          System.out.println("EXP: " + EXP);
          System.out.println("HP: " + playerHealth);
          System.out.println("Money: " + money);
          System.out.println("Name: " + name);
          System.out.println("Homeland: " + homeland );
          System.out.println("Skills: Fighting: " + fighting + " Block: " + block + "Doctor: " + doctor + " Speech: " + speech);
          System.out.println();
      }
  
      // Changes the player's level
      public void changeLevel(int newLevel) {         
          playerLevel = newLevel;
      }
  
      // Levels up the player
      public void levelUp() {
          playerLevel++;
          EXP = 0;
      }
  
      // Give the player health
      public void addHealth(int addedHealth) {
          playerHealth = playerHealth + addedHealth;
      }
  
      // Remove the player's health
      public void removeHealth(int removedHealth) {
          playerHealth = playerHealth - removedHealth;
      }
  
      // Give the player money
      public void giveMoney(int givenMoney) {
          money = money + givenMoney;
      }
  
      // Give the player EXP
      public void giveEXP(int addedEXP) {
          EXP = EXP + addedEXP;
      }
  
      // Change the player's homeland
      public void changeHomeland(String newHomeland) {
          homeland = newHomeland;
      }
  
      // Change the player's name
      public void changeName(String newName) {
          name = newName;
      }
  
      // Increase Fighting
      public void increaseFightingSkill(int amountAdded) {
          fighting = fighting + amountAdded;
      }
  
      // Decrease Fighting
      public void decreaseFightingSkill(int amountdecreased) {
          fighting = fighting - amountdecreased;
      }
  
      // Increase Block
      public void increaseBlockSkill(int amountAdded) {
          block = block + amountAdded;
      }
  
      // Decrease Block
      public void decreaseBlockSkill(int amountdecreased) {
          block = block - amountdecreased;
      }
  
      // Increase Doctor
      public void increaseDoctorSkill(int amountAdded) {
          doctor = doctor + amountAdded;          
      }
  
      // Decrease Doctor
      public void decreaseDoctorSkill(int amountdecreased) {
          doctor = doctor - amountdecreased;
      }
  
      // Increase Speech
      public void increaseSpeechSkill(int amountAdded) {
          speech = speech + amountAdded;
      }
  
      // Decrease Speech
      public void decreaseSpeechSkill(int amountdecreased) {
          speech = speech - amountdecreased;
      }
  
  }
  </code></pre>
  
  <p>As you can see, you can also alter the player's stats here. I'm making a main class, where I simply initialize the player, and modify their stats as the player makes decisions, wins battles, etc. I initialize the player here in the main class.</p>
  
  <pre><code>Player player = new Player();
  </code></pre>
  
  <p>Now that it is initialized, I made a "Battle" class. The concept is that I want to simply initialize the battle, and modify the contents of the battle and be done with it (like a battle template I can drop in the code). Sorta like this :</p>
  
  <pre><code>battle.enemySetHealth() // example modifier
  battle.start() // simply run through the battle
  </code></pre>
  
  <p>The problem is, I want to use the player stats in the battle class, without actually just defining another player, I want to use the same player object, because I will be modifying the player's stats in the main class, and if I define a new one, it will have different stats in the battle class, messing up the entire thing. I will use the player stats in the battle class to determine attack damage, chance to block incoming attacks, e.t.c. here is the battle class: </p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  
  // Battle Scene
  public class Battle {
      //Variables
      String enemyName = "Unnamed Enemy";
      int enemyHealth = 20;
      int enemyAttack = 5;
      int enemyDefense = 5;
      int enemyDisposition = 0;
      int attackDamage;
      // Sets up tools
      clear clear = new clear();
      Scanner sc = new Scanner(System.in);
      Random rand = new Random();
  
      // Allows changing of enemy name
      public void enemyName(String newEnemyName) {
          enemyName = newEnemyName;
      }
  
      // Sets a new disposition for the enemy to start the fight with
      public void enemyStartingDisposition(int newStartingDisposition) {
          enemyDisposition = newStartingDisposition;
      }
  
      // Sets a new amount of health for the enemy to start with
      public void enemyStartingHealth(int newStartingHealth) {
          enemyHealth = newStartingHealth;
      }
  
      // Sets a new defense for the enemy to start with
      public void enemyStartingDefense(int newEnemyDefense) {
          enemyDefense = newEnemyDefense;
      }
  
      // Sets a new attack for the enemy to start with
      public void enemyStartingAttack(int newEnemyAttack) {
          enemyAttack = newEnemyAttack;
      }
  
      // Starts the battle
      public void startFight() throws InterruptedException {
          System.out.println("Woah! " + enemyName + " jumped out of nowhere!!!");
          System.out.println("(Attack)");
          System.out.println("(Talk)");
          System.out.println("(Run)");
          while (true) {
              System.out.print("What should you do? : ");
              String userInput = sc.nextLine();
              if (userInput.equals("Attack")) {
                  // hopefully put in a way to attack based on your stats
              } if (userInput.equals("Talk")) {
                  // a way to use speech to talk your way out of the fight
              } if (userInput.equals("Run")) {
                  //ability to run away based on agility/speed 
              } else {
                  System.out.println();
                  System.out.println("Invalid Answer!");
                  Thread.sleep(2000);
                  clear.Screen();
              }   
          }
          //Break here
      }
  }
  </code></pre>
  
  <p>I also want to modify the player's stats at the end, like money and exp earned. So how can I do this? It is getting really confusing.</p>