Johan14th Johan14th - 1 month ago 5
Java Question

Can't seem to call or create a specific method drawAll()?

I am quite confused at the last step for my project can anyone explain this is the first part. Instructions haven't told me to create a drawAll()method so I assumed it was a graphics method but it doesn't appear on oracle? I'm new programmer help is appreciated. Thanks

After the sleep, call drawAll(g).
The drawAll method will print the following on the screen in black at position x=10 and y = 15:
Project 2 by YOURNAME.
Replace YOURNAME with your full name.




import java.awt.*;
public class Project2 {
public static final int PANEL_WIDTH = 300;
public static final int PANEL_HEIGHT = 300;
public static final int SLEEP_TIME = 50;
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(PANEL_WIDTH, PANEL_HEIGHT);
Graphics g = panel.getGraphics( );
startGame(panel, g);
}

public static void startGame(DrawingPanel panel, Graphics g) {

for (int i = 0; i <= 10000; i++) {
panel.sleep(SLEEP_TIME);
drawAll(g);

}
}
}

Answer
  public static void drawAll(Graphics g)
  {
    g.setColor(Color.BLACK);
    g.drawString("Project 2 by NAMEHERE", 1,15);
  }

public static void startGame(DrawingPanel panel, Graphics g) 
  {//start startGame
        for (int i = 0; i <= 10000; i++) {
        panel.sleep(SLEEP_TIME);
        drawAll(g);

        }
  }//end main game