title: Polymorphism with Abstract using Rectangle & Circle Shape Classes
body: <p>I am having trouble. Im suppose to draw rectangle and circle shapes using a test program. but I run it, It prints no values. I wonder should I set Values for each shape. I need help on this.</p>
  
  <p>This is the Figure class</p>
  
  <pre><code>public abstract class Figure{
      private int X, Y; // the center of the object.
      private String name;
      private static int numberOfShapes=0;
  
      public Figure(){
          X = 0;
          Y = 0;
          name = "none";
      }
      public Figure(int a, int b, String n){
          setX(a);
          setY(b);
          setName(n);
          numberOfShapes++;
      }
      public void setX(int a){X = a;}
      public void setY(int b){Y = b;}
      public void setName(String n){name = n;}
      public int getX(){return X;}
      public int getY(){return Y;}
      public String getName(){return name;}
      public static int getNumberOfShapes(){return numberOfShapes;}
      public abstract void erase();
      public abstract void draw();
      public void center(){
          System.out.println("\nIn Figure. Centering at ("+getX()+","+getY()+")");
      }
  </code></pre>
  
  <p>This is my Rectangle Class</p>
  
  <pre><code>public class Rectangle extends Figure {
      int length, height;
      public Rectangle(){
          super(0,0,"none");
          //setLength(0);
          //setHeight(0);
      }
      public Rectangle(String n,int a, int b, int h,int l){
          super(a,b,n);
          setLength(l);
          setHeight(h);
      }
      public String toString() {
          return "In Rectangle Drawing " + getName() + " centered at (" + getX() + "," + getY() + ") Length " + getLength() + " height " + getHeight();
      }
      public void erase(){
          System.out.println("In Rectangle erasing");
      }
      public void draw(){
          center();
          erase();
          System.out.println(""+this);
      }
  
      public void setLength(int l){length = l;}
      public void setHeight(int h){height = h;}
      public int getLength(){return length;}
      public int getHeight(){return height;}
  
  }
  </code></pre>
  
  <p>My Circle Class</p>
  
  <pre><code>public class Circle extends Figure {
          private double Radius;
          public Circle(){
              super(0,0,"none");
          }
          public Circle(String n, int a, int b){
              super(a,b,n);
          }
          public double getArea() {
              return Math.PI * Radius * Radius;
          }
  
          public void setRadius(double r){
              Radius = r;
          }
          public String toString(){
              return "In Circle Drawing "+getName()+" centered at ("+getX()+","+getY()+") Area "+getArea();
          }
          public void erase(){
              System.out.println("In Circle erasing");
          }
          public void draw(){
              erase();
              System.out.println(""+this);
          }
          public void setRadius(int r){Radius = r;}
          public double getRadius(){return Radius;}
  
  
  
  }
  </code></pre>
  
  <p>This is my Test Class</p>
  
  <pre><code>import java.util.*;
  
  public class Testshape{
      public static void main(String[] args){
          //Scanner s = new Scanner(System.in);
  
          Rectangle r = new Rectangle();
          //Rectangle ry = new Rectangle();
  
  
  
  
          System.out.println("In Rectangle erasing");
          System.out.println(r);
  
  
  
  
      }
  }
  </code></pre>
  
  <p>MY OUTPUT FORMAT SUPPOSE TO BE LIKE THIS:</p>
  
  <p><a href="https://i.stack.imgur.com/b6ceD.png" rel="nofollow">The Output</a></p>