I have this if statement and what to access axeMinDmg. How do i set it as a global variable to so that i can access it within the if statement. Also, how to i set minDmg as a global variable so that i can access outside of the if statement. thanks
// if yes ask what weapon to purchase
if (name.equals("yes")){
System.out.println("Select Your Weapon \n axe \n bat \n sword : \n ");
Scanner wc = new Scanner(System.in);
String weapon = wc.next();
if(weapon.equals("axe")){
minDmg = axeMinDmg;
} else {
System.out.println();
} // close if statement
Global variables really does not exists in Java. You can create a public static final member of a class and the member will accesible in the same scope as the class (if public everywhere)
can be used as MyClass.axeMinDmg from everywhere.
Another way could be to go with an Enum.