숙제가 있습니다. 작은 그래픽 프로그램의 도우미 메서드를 작성해야합니다. 내가 가지고있는 문제는 내가 오류가 있다는 말을 계속하고있다.도움말 방법을 호출하는 방법
기호 - 메소드 drawPolygon (gp, int, int)을 찾을 수 없습니다.
무엇이 누락 되었습니까?
추신. 나는 GraphicsPanel 코드가 여기에 없다는 것을 알고 있지만 "기호를 찾을 수 없습니다"오류가 발생하는 이유가 궁금합니다. 을 쓸 때 drawPolygon (gp, 50, 4)을 단지으로 작성하면 오류없이 컴파일되지만 패널에는 아무 것도 그려지지 않습니다.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class G5 {
public static void drawPolygon(GraphicsPanel gp, int sideCount, int sideLength) {
for (int i = 0; i < 4; i++) {
gp.draw(sideLength);
gp.turn(360/sideCount);
}
}
public static void main(String[] args) {
GraphicsPanel gp = new GraphicsPanel();
gp.setBackgroundColor(Color.BLACK);
gp.delay(1000);
int x = gp.getWidth()/2;
int y = gp.getHeight()/2;
gp.setLocation(x, y);
gp.setColor(Color.RED);
gp.drawPolygon(gp, 50, 4);
gp.clear();
}
}
를 사용 http://meta.stackexchange.com/questions/147100/the-homework-tag-is-now ([I는 숙제 태그를 제거] - 비공식적으로 사용되지 않음). 어쨌든 질문에서 분명해야합니다 :) – Patrick