title: java-- Geometric shapes with polymorphism and encapsulation
body: <p>Just to make sure this is my homework assignment. I need to implement classes to calculate area and perimeter of geometric shapes.</p>
  
  <p>Overview of what I need: I will give something like "java ShapeTest Rectangle 5 5" in command line which should give area and perimeter of that rectangle.</p>
  
  <p>Here is my code:</p>
  
  <p>Shape.java</p>
  
  <pre><code>public abstract class Shape {
  public abstract double area();
  public abstract double perimeter();
  }
  </code></pre>
  
  <p>Rectangle.java</p>
  
  <pre><code>public class Rectangle extends Shape {
  private double b;
  private double a;
  
  public Rectangle(){
  
  }
  
  public Rectangle(double a, double b) {
      this.a = a;
      this.b = b;
  }
  
  @Override
  public double area(){
      return a *b;
  }
  
  @Override
  public  double perimeter(){
      return 2*(a+b);
  }
  
  @Override
  public String toString() {
      return "Rectangle{" +
              "a=" + a +
              " b=" + b +
              '}';
  }
  }
  </code></pre>
  
  <p>I have similar Circle, Triangle and Sqaure.java.
  This is my ShapeTest.java</p>
  
  <pre><code>public class FormenTest {
  
  
  public static void set(){
  //I want something here
  
  
  }
  
  public static void main(String[] args) {
  
      Rectangle rectangle = new Rectangle(Character.getNumericValue((args[1].charAt(0))),Character.getNumericValue((args[2].charAt(0))) );
  
      if(args[0].equals("Rectangle")){
          System.out.println(rectangle.area());
  
          }
      }
  }
  </code></pre>
  
  <p>Now, this kind of does what is needed but I don't think this is nice way to do it. In the set method inside <code>ShapeTest</code> class I want to generate shape object which I later use in main method. Any help regarding optimizing the code and filling set method will be appreciated.</p>