Shape.java
Select all
/* Shape.java CIS 260 2005-02-09 David Klick This is a demonstration of an abstract class. It is like any other class, except that it has at least one abstract (non-implemented) method. This class actually has two abstract methods, one from implementing the Drawable interface, and one of its own. Any classes which subclass this class must implement all abstract methods if objects are to be instantiated from them. */ abstract class Shape extends Object implements Drawable { private static int count = 0; protected Point origin = new Point(0,0); public Shape() { count++; } public Shape(int x, int y) { origin.x = x; origin.y = y; } public Shape(Point p) { origin.x = p.x; origin.y = p.y; } public void finalize() { count--; } public int getCount() { return count; } abstract public double area(); }