这个是我那个画圆的类
public class MyCircle implements Drawable
{
    Point m_pCenter;
    double m_dRadius;
    int m_width;
    public MyCircle(Point p,double r)
    {
        m_pCenter.x=p.x-(int)r;
        m_pCenter.y=p.y-(int)r;
        m_dRadius=r;
        m_width=(int)m_dRadius;
        
        
    }
    
    public MyCircle(Point p,int width)
    {
        m_width=width;
        m_pCenter=p;
    }
    
    Point getCenter()
    {
        return m_pCenter;
    }
    
    double getRadius()
    {
        return m_dRadius;
    }
    
    double calculatePerimeter()
    {
        return 2*Math.PI*m_dRadius;
    }
    
    double calculateArea()
    {
        return Math.PI*m_dRadius*m_dRadius;
    }
    
    boolean drawMyCircle(Graphics g)
    {
        g.drawOval(m_pCenter.x,m_pCenter.y,m_width,m_width);
        return true;
    }}

解决方案 »

  1.   

    没看到你在画圆的类中实现了drawShap()方法
      

  2.   

    这是一个多态的问题:
    public interface Drawable
    {
    abstract drawShape();

    }
    Drawable 是一个interface,里面的method都是abstract
    MyCirle与MyRectangle都是implement Drawable,如果这两个类本身不是abstract,那么这两个类里面必需实现drawShape()这个方法。
      

  3.   

    我贴出的那个没有加drawShape()但是我该加什么才能实现呢?我现在还不太明白它让构造这个drawShape是想达到什么目的?是说用这个都可以画出东西?
      

  4.   

    在你画矩形和圆的类里实现drawShape()方法,我看你直接把boolean drawMyCircle(Graphics g)改成boolean drawMyCircle( Graphics g )就行,然后再Drawable aaa = new MyCircle(); 
    aaa.drawShape();就行了
      

  5.   

    如果你的类(class)不是抽象类(abstract class),那么如果你要实现(implements)一个接口(interface),你就必须实现接口中定义的所有的函数。
      

  6.   

    我写好了CLASS里面的接口定义的函数的实现方法。但是一编译就显示接口里面的abstract drawShape()  <identifier> expected
      

  7.   

    接口函数的返回类型?public interface Drawable
    {
    void drawShape();

    }