title: Java Program that shows the number of shapes in a geometric figure interactively
body: <p>I have this java program that is supposed to show the number of sides of geometrical shapes of Triangle, Trapezoid and Hexagon. I managed to create the codes such that when I ran the java Shape its shows all the Shapes and the sides all at once, but I want to make it interactive such that a user can be prompted to enter the shape she wants and the return is the number of sides of it, which functionality in Java can best do this? </p>
  
  <pre><code>public abstract class Shape {
  
      public abstract void numberOfSides();
  
      public static void main(String[] args)
      {
          System.out.println("The Geometrical characteristics of the figures are as follows");
  
          Trapezoid t=new Trapezoid();
          Triangle tg=new Triangle();
          Hexagon h=new Hexagon();
          t.numberOfSides();
          tg.numberOfSides();
          h.numberOfSides();
      }
  }
  class Trapezoid extends Shape {
      public void numberOfSides()
      {
          System.out.println("Trapezoid~It is geometrical figure with an attribute of 4 sides (Of which two are parallel and with no angles)");
      }
  }
  class Triangle extends Shape {
      public void numberOfSides()
      {
          System.out.println("Triangle~It is geometrical figure with an attribute of 3 sides");   
      }
  }   
  class Hexagon extends Shape {
      public void numberOfSides()
      {   
          System.out.println("Hexagon-It is geometrical figure with an attribute of 6 sides");
      }
  }
  </code></pre>
  
  <p>This is my new cord after trying to implement above, its says errors exist, obsolete methods.. </p>
  
  <pre><code>import java.io.*;
   public abstract class Shape {
  
      public abstract void numberOfSides();
  
      public static void main(String[] args) 
      {  
          System.out.println("Enter the name of the Shape");
          BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
          try {
          String shapeName = br.readLine();
  
          if (br.equals ("Trapezoid"))
                  {Trapezoid t = new Trapezoid();
                  t.numberOfSides();
                  }
          else if (br.equals ("Triangle"))    
                  {Triangle tg = new Triangle();
                  tg.numberOfSides();
                  }
          else if (br.equals ("Hexagon")) 
                  {Hexagon h = new Hexagon();
                  h.numberOfSides();
                  }
                  }    
  }
  class Trapezoid extends Shape {
      public void numberOfSides()
  {
          System.out.println("Trapezoid~It is geometrical figure with an attribute of 4 sides (Of which two are parallel and with no angles)");
  }
  }
  class Triangle extends Shape {
      public void numberOfSides()
  {
          System.out.println("Triangle~It is geometrical figure with an attribute of 3 sides");   
  }
  }   
  class Hexagon extends Shape {
      public void numberOfSides()
  {   
          System.out.println("Hexagon-It is geometrical figure with an attribute of 6 sides");
  }
  }
  </code></pre>