title: Implementing a Shapes application using the following criteria - small project
body: <p>Create a Shape interface which has an area() method which returns the area of the shape as a double. Create classes Circle and Rectangle which implement the Shape interface. These classes have attributes which reflect their dimensions (radius for a circle, height and width for a rectangle) which are set by their constructors. </p>
  
  <p>Create a Drawable interface with setColour(Color c), setPosition(int x, int y), and draw(Graphics g) methods. Create the classes DrawableCircle and DrawableRectangle with appropriate constructors which extend Circle and Rectangle respectively and implement the Drawable interface.</p>
  
  <p>Create a ShapesDriver class which extends Frame and has the main and  paint(Graphics g) methods in it. Within ShapesDriver create an ArrayList of type Drawable. Place into this array list a DrawableCircle and a DrawableRectangle where you have set the dimensions, position and colour. In the paint method iterate through the ArrayList and the invoke the draw method for each shape.</p>
  
  <p>Here's where I've got to but I can't seem to get the drawable classes to work?</p>
  
  <p>package shape;</p>
  
  <pre><code>public interface Shape
  {
      public double area();
  }
  </code></pre>
  
  <p>package shape;</p>
  
  <pre><code>public abstract class Circle implements Shape
  {
      private double radius;
  
      Circle(double radius)
      {
          this.radius = radius;
      }
  
      public double area()
      {
          return radius;
      }
  
  }
  </code></pre>
  
  <p>package shape;</p>
  
  <pre><code>public abstract class Rectangle implements Shape
  {
      public double height, width;
  
      Rectangle(double Height, double Width)
      {
          this.height = Height;
          this.width = Width;
      }
  
      public double area()
      {
          return width * height;
      }
  }
  </code></pre>
  
  <p>package shape;</p>
  
  <pre><code>import java.awt.*;
  
  public interface Drawable
  { 
      public void setColour(Color c);
      public void setPosition(double x, double y);
      public void draw(Graphics g);
  }
  </code></pre>
  
  <p>package shape;</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Graphics;
  
  public class DrawableCircle extends Circle implements Drawable
  {
      public DrawableCircle(double radius)
      {
          super(radius);
      }
  
      @Override
      public void setColour(Color c)
      {
          c = Color.ORANGE;
      }
  
      @Override
      public void setPosition(int x, int y)
      {
          x = 100;
          y = 150;
      }
  
      @Override
      public void draw(Graphics g)
      {
          //g.drawOval(x, y, width, height);
      }
  
  }
  </code></pre>
  
  <p>package shape;</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Graphics;
  
  public class DrawableRectangle extends Rectangle implements Drawable
  {
      private double x, y;
  
      public DrawableRectangle(double height, double width)
      {
          super(height, width);
      }
  
      @Override
      public void setColour(Color c)
      {
          this.setColour(c);
      }
  
      @Override
      public void setPosition(double x, double y)
      {
          this.x = x;
          this.y = y;
      }
  
      @Override
      public void draw(Graphics g)
      {
          g.drawRect(x, y, width, height);
      }
  
  }
  </code></pre>