Gym.java
public class Gym extends ActiveObject {
public void run() {
...
}
}
GymController.java
public class GymController extends WindowController implements KeyListener{
private Gym gym;
public void begin() {
Gym gym = new gym(canvas, new Location(dx, dy), delay, this);
}
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_SPACE) {
gym.run();
}
}
}
There is an object and its moving code in Gym.java file... and I wanted to call that to GymController.java file's keyPressed method... so that the object moves when the user presses the space bar. How do I even link these two files in the first place...? But the compiler is giving me an error saying that it cannot find symbol. How can I call a method from another .java file into current file's keyPressed method properly, so that it compiles...?