class cirde
{
      public double radius;
      final double PI =3.1415926;
      cirde(double radius)
      {
            this.radius = radius;
      }
      public double area()
      {
             return radius*radius*PI;
      }
      public double girth()
      {
             double girth;
             girth = 2*radius*PI;
             return girth;
      }
}
class InsideSquare extends cirde
{
      InsideSquare(double radius)
      {
             super(radius);
      }
      public double area()
      {
             double temp;
             double area;
             temp = radius/Math.sqrt(2);    //\'b0\'eb\'be\'b6\'b3\'fd\'d2\'d4\'b8\'f9\'ba\'c52\par 
             area = Math.pow((2*temp),2);   //\'c6\'bd\'b7\'bd\par 
             return area;
      }
      public double girth() 
      {
             double temp;
             double girth;
             temp = radius/Math.sqrt(2);     
             girth = 4*(2*temp);             
             return girth;  
      }
}
class OutsideSquare extends cirde
{
      OutsideSquare(double radius)
      {
             super(radius);
      }
      public double area()
      {
             double temp;
             double area;
             temp = 2*radius;
             area = Math.pow(temp,2);
             return area;
      }
      public double girth() 
      {
             double temp;
             double girth;
             temp = 2*radius;
             girth = 4*temp;
             return girth;
      }
}
public class shapeArea
{
       public static void main(String[] asgs)
       {
              cirde shape = new cirde(10);
              System.out.println(" " + shape.area);
              System.out.println(" " + shape.girth);
              InsideSquare shape2 = new InsideSquare(10);
              System.out.println(" " + shape2.area);
              System.out.println("  " + shape2.girth);
              OutsideSquare shape3 = new OutsideSquare(10);
              System.out.println(" " + shape3.area);
              System.out.println(" " + shape3.girth);
       }
}

解决方案 »

  1.   

    class cirde
    {
          public double radius;
          final double PI =3.1415926;
          cirde(double radius)
          {
                this.radius = radius;
          }
          public double area()
          {
                 return radius*radius*PI;
          }
          public double girth()
          {
                 double girth;
                 girth = 2*radius*PI;
                 return girth;
          }
    }
    class InsideSquare extends cirde
    {
          InsideSquare(double radius)
          {
                 super(radius);
          }
          public double area()
          {
                 double temp;
                 double area;
                 temp = radius/Math.sqrt(2);    //\'b0\'eb\'be\'b6\'b3\'fd\'d2\'d4\'b8\'f9\'ba\'c52\par 
                 area = Math.pow((2*temp),2);   //\'c6\'bd\'b7\'bd\par 
                 return area;
          }
          public double girth() 
          {
                 double temp;
                 double girth;
                 temp = radius/Math.sqrt(2);     
                 girth = 4*(2*temp);             
                 return girth;  
          }
    }
    class OutsideSquare extends cirde
    {
          OutsideSquare(double radius)
          {
                 super(radius);
          }
          public double area()
          {
                 double temp;
                 double area;
                 temp = 2*radius;
                 area = Math.pow(temp,2);
                 return area;
          }
          public double girth() 
          {
                 double temp;
                 double girth;
                 temp = 2*radius;
                 girth = 4*temp;
                 return girth;
          }
    }
    public class shapeArea
    {
           public static void main(String[] asgs)
           {
                  cirde shape = new cirde(10);
                  System.out.println(" " + shape.area());
                  System.out.println(" " + shape.girth());
                  InsideSquare shape2 = new InsideSquare(10);
                  System.out.println(" " + shape2.area());
                  System.out.println("  " + shape2.girth());
                  OutsideSquare shape3 = new OutsideSquare(10);
                  System.out.println(" " + shape3.area());
                  System.out.println(" " + shape3.girth());
           }
    }
      

  2.   

    System.out.println(" " + shape.area());
    System.out.println(" " + shape.girth());调用的是方法。加()