Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
class TestThis{
    public static void main(String args[]){
        shape cir = new shape();
        cir.equals(circ);


    }
}
class shape{
    class circle{
   double area(double radius){
        double area = 3.14*radius*radius;
        return(area);
   }
   double perameter(double radius){
       double perameter =3.14*radius;
       return(perameter);
}
   class rectangle{
       double area(double length,double breath){
       double area = length*breath;
       return(area);
       }
       double perameter(double length,double breath){
         double perameter = 2*length*breath;
         return(perameter);
     }
   }
  }
}
Posted
Comments
CPallini 14-Sep-14 3:16am    
Please review your class hierarchy. The usual paradigm is both rectangle and circle inheriting from shape.

1 solution

Create an object of the class, then call the method of that specific class using the objects:
Java
class TestThis {
    public static void main(String args[]) {

    rectangle rec = new rectangle();
    rec.parameter(length, breadth);
    rec.area(length, breadth);

    circle circ = new circle();
    circ.area(radius);

}


But something I don't understand is the what is the work of the
Java
class shape
.
I hope I answered your question.

Regards.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900