madhawaseeeee

sphere2

Sep 17th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1.  
  2. class Sphere extends PaintShape {
  3.  
  4.     final static double i = 3.14;
  5.     double radius;
  6.  
  7.     public Sphere(String shapeName, int coverage) {
  8.         super(shapeName, coverage);
  9.     }
  10.  
  11.     public double area() {
  12.  
  13.         return 4 * Sphere.i * radius * radius;
  14.  
  15.     }
  16.  
  17.     public static void main(String[] args) {
  18.  
  19.         Sphere sp = new Sphere("sphere",350);
  20.         sp.radius=15;
  21.        
  22.         System.out.println("computing amount for shape: sphere is " +sp.amount());
  23.         //PaintShape ps=new PaintShape("name",24);
  24.  
  25.     }
  26.  
  27. }
Add Comment
Please, Sign In to add comment