So I'm trying to get one of the values out of the stats ArrayList from a different class than the one I'm currently in.
I want to get the int in the stats of the specifiedCPU that is declared in BattlePage. Problem is when I assign the getCPU() to the variable enemy in the current class and then try to do getStats(), it gives me an error. I think this makes sense, so please help.
Current class:
BattlePage class:
public void Attack()
{
Moves m1 = new Moves("Skull Bash",130,100,"Normal","Physical");
Moves m2 = new Moves("Hydro Pump",110,80,"Water","Special");
Moves m3 = new Moves("Ice Beam",90,100,"Ice","Special");
Moves m4 = new Moves("Weather Ball",50,100,"Normal","Special");
Moveset ms = new Moveset(m1,m2,m3,m4);
Scanner scan = new Scanner(System.in);
System.out.println("Enter: Fight or Run");
if(scan.nextLine().toLowerCase()=="fight")
{
System.out.println("Choose a move: ");
for(int i = 0; i < 4;i++)
{
ArrayList<Moves> x = ms.getMoveset();
System.out.println("- " + x.get(i).getName());
}
if(scan.nextLine().toLowerCase() == "skull bash")
{
int power = m1.getPower();
double random = (Math.random()*0.85)+0.15;
Actor enemy = BattlePage.getCPU();
ArrayList<Integer> enemyDefense = getStats();
}
}
}
public ArrayList<Integer> getStats()
{
return stats;
}
}public class BattlePage extends World
{
private static Actor selectedPlayer;
private static Actor selectedCPU;
/**
* Constructor for objects of class BattlePage.
*
*/
public BattlePage()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
setBackground("battle_background.jpg");
addObject(selectedCPU,500,100);
addObject(selectedPlayer,150,275);
}
public static Actor getPlayer()
{
return selectedPlayer;
}
public static Actor getCPU()
{
return selectedCPU;
}
public static void setPlayer(Actor player)
{
selectedPlayer = player;
}
public static void setCPU(Actor CPU)
{
selectedCPU = CPU;
}
}

