자바초급자예요ㅠㅠ도와주세요ㅠㅠ
쇼코홀릭
Shape 클래스를 상속받아서 Triangle과 DrawableTriangle 그리고 Drawable 인터페이스를 작성해서 프로그램을 짜는건데요
DrawableTriangle 에서 에러가 나네요 도와주세요ㅠㅠ
Shape.java
public abstract class Shape {
protected int x, y;
public abstract double area();
public abstract double circumference();
public void move(int x1, int y1){
x += x1;
y += y1;
}
}
Drawable.java
import java.awt.Graphics;
interface Drawable{
void paint(Graphics g);
}
Triangle.java
public class Triangle extends Shape{
protected int width, height;
public Triangle(){
this(0,0);
}
public Triangle(int w, int h){
width = w;
height = h;
}
public double circumference(){
return 2*Math.sqrt(width/2*width/2 + height*height)*height;
}
public double area(){
return (width*height)/2;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public void setSize(int w, int h){
width = w;
height = h;
}
}
DrawableTriangle.java
import java.awt.*;
public class DrawableTriangle extends Triangle implements Drawable{
public DrawableTriangle(){
this(0,0,0,0);
}
public DrawableTriangle(int x, int y, int w, int h){
super(w, h);
this.x = x;
this.y = y;
}
public void paint(Graphics g){
g.drawTriangle(x, y, width, height);
g.drawString(Stirng.valueOf(area()), x-width/2, y+height/2); ---이부분이 에러가나요ㅠㅠ
}
}
DrawingFrame
import java.awt.*;
import javax.swing.*;
public class DrawingFrame extends JFrame {
protected Drawable drawable[];
public DrawingFrame(){
super(그림판);
drawable = new Drawable[3];
drawable[0] = new DrawableCircle(65, 75, 30);
drawable[1] = new DrawableRect(125, 125, 70, 65);
drawable[2] = new DrawableCircle(230,100,60);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400,300);
setVisible(true);
}
public void paint(Graphics g){
int n = drawable.length;
for(int i=0; in; i++){
drawable[i].paint(g);
}
}
public static void main(String args[]){
new DrawingFrame();
}
}
-
치에미
빨간줄만 에러나는게 맞죠?
Stirng로 바꾸세요 오타입니다
다른 부분은 소스가 누락되서 모르겠네요
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700452 | c언어에서... 자료형 구분.... (3) | 시내 | 2025-07-05 |
2700422 | 버전에 관해 질문 | 라온제나 | 2025-07-04 |
2700393 | mysql이 갑자기!!!!!!!!!!!!!!!에러가;; (2) | 소미 | 2025-07-04 |
2700359 | 3.0 ) SimpleButton 상태 강제 변경 (3) | 희선 | 2025-07-04 |
2700304 | ie8 전용핵 문의 (3) | 여자 | 2025-07-03 |
2700281 | 이런경우 어떻게 코딩해야 표준에 따르는건가요? (6) | 늘솜 | 2025-07-03 |
2700230 | 질문이여 ! | 뿡뿡몬 | 2025-07-03 |
2700205 | 액션스크립트책 좀 추천해주세요. (10) | 화이트캣 | 2025-07-02 |
2700173 | 자바 소스인데 어떤게 에러인지..? (1) | 호빵녀 | 2025-07-02 |
2700142 | 하단이 붙어있는 가변 레이아웃구조 질문드립니다. | 이플 | 2025-07-02 |
2700089 | 이미지를 사다리꼴로 비틀게 하는 액션코드가 있나요? (4) | 여름 | 2025-07-01 |
2700033 | 배경에 그라데이션을 넣으려고 하는데요.. (4) | 화이티 | 2025-07-01 |
2700005 | [질문] TextField 객체의 실제 높이 알아오는 방법 ? | 천사의눈물 | 2025-07-01 |
2699978 | FileReferenceList를 이용하여 업로드시 자꾸 실행속도가 느리다는 팝업이... (10) | 데이비드 | 2025-06-30 |
2699944 | 자바스크립트가 많은 사이트는... (6) | 희나리 | 2025-06-30 |
2699918 | 브라우저마다 다른 input과 텍스트 정렬 (3) | 늘봄 | 2025-06-30 |
2699887 | 동적텍스트를 그래픽으로?? (2) | 족장 | 2025-06-30 |
2699862 | scope넣기 (1) | 아인 | 2025-06-29 |
2699835 | exe로 만드는 방법을....알려주세요.. (5) | 방방 | 2025-06-29 |
2699809 | 롤오버할때 백그라운드 이미지로할때 alt설명은 어떻게해야하죠?..ㅠ (4) | 반혈 | 2025-06-29 |