I'm trying to make a Shape into a Polygon. My code looks something like this:
class MyGraphicMethods extends Graphics
{
...
...
public void fillShape(Shape S)
{
g.fillPolygon((Polygon)S);
}
When I run
public static void main(String[] args) {
Shape S=new Rectangle(new Dimension(10, 100));
Polygon P=(Polygon)S;
}
I get a ClassCastException. Can Somebody help me?