实际和形式参数列表在子类中的长度错误不同

时间:2017-05-01 00:53:51

标签: java inheritance polymorphism

我在子类中遇到错误: “DrawingShape类中的构造函数DrawingShape无法应用于给定类型;必需:java.awt.geom.Point2D.Double,double,java.awt.color 发现:没有争论 原因:实际和正式的参数列表长度不同

import java.awt.Color;
import java.awt.geom.Point2D;
import java.awt.Graphics2D;
/**
 * Abstract class DrawingShape - a two dimensional circle or square
 *
 * @author Aidan H
 * @version 4/29/2017
 */
public abstract class DrawingShape  
{
    //center and radius of the shape
    private double radius;
    private Point2D.Double center;
    //color of the shape
    private Color color;
    /**
     * Creates a shape with the center
     * at the specified point and 
     * with the specified radius and color.
     * 
     * @param   Point2D.double   the center of the shape
     *          double           the radius of the shape
     *          Color            the color of the shape
     */
    public DrawingShape(Point2D.Double center, double radius, Color color)
    {
        this.center = center;
        this.radius = radius;
        this.color = color;
    }
    //get and set methods, etc
}

import java.awt.Color;
import java.awt.geom.Point2D;
import java.awt.Graphics2D;
/**
 * Write a description of class Circle here.
 * 
 * @author Aidan H
 * @version 4/29/2017
 */
public class Circle extends DrawingShape /*error underlines "cl" in "public class Circle"*/
{
    //center and radius of the circle
    private double radius;
    private Point2D.Double center;
    //color of the circle
    private Color color;
    /**
     * Creates a circle with the center
     * at the specified point and 
     * with the specified radius and color. 
     * 
     * @param   Point2D.double   the center of the shape
     *          double           the radius of the shape
     *          Color            the color of the shape
     */
    public void Circle(Point2D.Double center, double radius, Color color)
    {
        this.center = center;
        this.radius = radius;
        this.color = color;
    }
    //more methods
}

0 个答案:

没有答案