I’m sure I’m missing something silly, here is my code:
public class clearBlankGrid {
public static void main(String args[]) {
Monster myMonster = new Monster(10,10,5,5,1);
MonsterGUI myGUI = new MonsterGUI(myMonster);
if (myMonster.getRows() > 0) {
// 0 = North, 1 = East, 2 = South, 3 = West
myMonster.setFacing(3);
myMonster.setIcon();
}
}
public static void keepClearing() {
myMonster.isGridCleared(); // Cannot find symbol 'myMonster'
}
}
myMonsterneeds to be a static member if you want to access it in thekeepClearingmethod (which is static).Note: For reference you could also avoid making the
Monstermember static by actually instantiating yourclearBlankGridclass.Monstercan then be an instance variable ofclearBlankGridwhich means thekeepClearingmethod no longer has to be static.