6-1 Circle_Object

posted Apr 9, 2014, 2:07 PM by Dlovan ismail


package circle_object;

public class Circle 
{
       private double radius; 

       void Set_Radius(double r)
       {
          radius=r; 
       }

       double get_Radius()
       {
          return radius; 
       }

       double Display_Area()
       {
          return Math.pow(radius,2)*Math.PI; 
       }
}




package circle_object;

public class Circle_Object 
{

    public static void main(String[] args) 
    {

            Circle box=new Circle();  // Create a Circle object. 
            box.Set_Radius(4);
            System.out.println("The area of the circle of radius " + box.get_Radius()+" is " + box.Display_Area());

    }
    
}


ċ
Circle.java
(0k)
Dlovan ismail,
Apr 9, 2014, 2:08 PM
ċ
Circle_Object.java
(0k)
Dlovan ismail,
Apr 9, 2014, 2:08 PM
Comments