I declared a public int in one class, modified it in that class, then tried to call it in another class, but when I call it, none of the modifications that were made carry over.
The variable:
public int dmg = 5;
Where it is modified:
What this is doing is buying a weapon, then adding to the dmg int.case 1: if (gold >= 2){ dmg += 10; gold -= 2; out.println("Thank you. Have a nice day!"); } else{ out.println("You are too poor."); } decision = 0; break;
Where it is being called:
this is a simple battle scenario, and when i run it, instead of saying 15 damage it just says 5.static town city = new town(); public int dmg(){ return dmg; case 1: wolf1hp -= city.dmg(); out.println("You have dealt " + city.dmg() + " damage." ); if (wolf1hp <= 0){ out.println(" You killed the first wolf."); } playerhealth -= wolf2dmg; out.println("Wolf 2 attacked you and you lost " + wolf2dmg + ". You now have " + playerhealth + " health."); decision = 0; break;