“n'est pas abstrait et ne remplace pas la méthode abstraite” erreur

J'obtiens cette erreur et il est source de confusion pour moi. Je ne sais pas comment le résoudre. Je sais qu'il y a quelques autres erreurs là, mais je ne suis pas trop inquiet à propos de ceux qui pour l'instant.

Voici le code:

import java.awt.*;

public abstract class Shape {
//Instance variables
private int x;
private int y;
private Color color;

//Constructor
protected Shape(int x, int y, Color color) {
this.x = x;
this.y = y;
this.color = color;
}

//Abstract methods
 public abstract void draw(Graphics g);
public abstract int getHeight();
public abstract int getWidth();
public abstract void scale();
public abstract double area();

//Other instance methods
public Color getColor() {
return color;
}

public int getX() {
return x;
}

public int getY() {
return y;
}

public void move(int dx, int dy) {
x += dx;
y += dy;
}

public void setColor(Color color) {
this.color = color;
}

public String toString() {
return "Position: (" + getX() + ", " + getY() + ") Color: (" + getRed() + ", " + getBlue() + ", " getGreen() + ")";

}
}

Voici les fichiers de classe:

//Represents a circle that can be displayed in a graphics
//context
import java.awt.*;
public class Circle extends Shape {
//Instance variables
private int diameter;
private double scaleFactor = 2;
private double area;
//Constructor
public Circle(int x, int y, Color color, int diameter) {
super(x, y, color);
this.diameter = diameter;
}
//Instance methods
public void draw(Graphics g) {
g.setColor(getColor());
g.fillOval(getX(), getY(), diameter, diameter);
}
public int getHeight() {
return diameter;
}
public int getWidth() {
return diameter;
}
public void scale(double scaleFactor) {
(double) diameter *= scaleFactor;
}
public double area() {
area = (3.14 * (diameter * diameter)) / 4;
return area;
}
public String toString() {
return "Diameter: " + diameter + "\nWidth: " + getWidth() + "Height: " + getHeight();
}
}
import java.awt.*;
public class Rectangle extends Shape {
//Instance variables
private int width;
private int height;
private double scaleFactor = 2;
private double diameter = width * height;
private double area;
//Constructor
public Rectangle(int x, int y, Color color,
int width, int height) {
super(x, y, color);
this.width = width;
this.height = height;
}
//Instance methods
public void draw(Graphics g) {
g.setColor(getColor());
g.fillRect(getX(), getY(), width, height);
}
public int getHeight() {
return height;
}
public int getWidth() {
return width;
}
public void scale(double scaleFactor){
width *= scaleFactor;
height *= scaleFactor;
}
public double area() {
area = (3.14 * (diameter * diameter)) / 4;
return area;
}
public String toString() {
return "Diameter: " + diameter + "\nWidth: " + getWidth() + "Height: " +
getHeight();
}
}

Et voici le fichier de test:

public class ShapeTest
{
public static void main(String[] args)
{
Color myC = new Color(10, 30, 20);
Circle myCircle = new Circle(0, 0, myC, 5);
Rectangle myRectangle = new Rectangle(0, 0, myC, 2, 3);
System.out.println(myCircle.toString());
System.out.println(myRectangle.toString()); 
}
}

Voici les erreurs:

javac ShapeTest.java
ShapeTest.java:5: cannot find symbol
symbol  : class Color
location: class ShapeTest
Color myC = new Color(10, 30, 20);
^
ShapeTest.java:5: cannot find symbol
symbol  : class Color
location: class ShapeTest
Color myC = new Color(10, 30, 20);
^
./Shape.java:46: ';' expected
return "Position: (" + getX() + ", " + getY() + ") Color: (" + getRed() + ", " +   getBlue() + ", " getGreen() + ")";
^
./Shape.java:46: not a statement
return "Position: (" + getX() + ", " + getY() + ") Color: (" + getRed() + ", " + g etBlue() + ", " getGreen() + ")";
^
./Shape.java:46: cannot find symbol
symbol  : method getRed()
location: class Shape
return "Position: (" + getX() + ", " + getY() + ") Color: (" + getRed() + ", " + getBlue() + ", " getGreen() + ")";
^
./Shape.java:46: cannot find symbol
symbol  : method getBlue()
location: class Shape
return "Position: (" + getX() + ", " + getY() + ") Color: (" + getRed() + ", " + getBlue() + ", " getGreen() + ")";
^
./Shape.java:46: cannot find symbol
symbol  : method getGreen()
location: class Shape
return "Position: (" + getX() + ", " + getY() + ") Color: (" + getRed() + ", " + getBlue() + ", " getGreen() + ")";
^
./Circle.java:16: Circle is not abstract and does not override abstract method scale() in     Shape
public class Circle extends Shape {
^
./Circle.java:43: unexpected type
required: variable
found   : value
(double) diameter *= scaleFactor;
^
./Rectangle.java:3: Rectangle is not abstract and does not override abstract method scale() in Shape
public class Rectangle extends Shape {
^
10 errors
Vous avez besoin d'importer votre Color, Circle et Rectangle classes dans votre ShapeTest classe.
Sûrement pas tous du même code est pertinent à votre problème.
Vous êtes également en manque un + sur la ligne 46 de Shape.java.

OriginalL'auteur TheNameHobbs | 2012-10-11