So we are making an Avatar for a game and we have already created the Avatar as an Avatar
class file. Our problem is that in our class file Game
we are having difficulty declaring Avatar as an instance variable.
The code is as follows:
public class Game extends JApplet {
private static final long serialVersionUID = 1L;
public static final long WIDTH = 800;
public static final long HEIGHT = 600;
// Declare an instance variable to reference your Avatar object
public @Override void init() {
// Store an instantiated Avatar into the instance variable
setSize(new Dimension( WIDTH, HEIGHT));
getContentPane().setBackground(Color.BLUE);
}
public @Override void paint(Graphics g) {
super.paint(g); // Call the JAplet paint method (inheritance)
// Call the draw method in your Avatar class
}
}