Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Sphere

By: droidus on Oct 24th, 2011  |  syntax: Java  |  size: 0.35 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class sphere extends Shape {
  2.        
  3.         private double r;
  4.        
  5.         public sphere(String color, double a, double c, double r) {
  6.                 super (color);
  7.                 volume();
  8.                 surfaceArea();
  9.                 this.r = r;
  10.         }
  11.        
  12.         public void volume () {
  13.                 volume = (4/3) * super.pi * Math.pow(r, 3);
  14.         }
  15.        
  16.         public void surfaceArea() {
  17.                 surfaceArea = 4 * super.pi * Math.pow(r, 2);
  18.         }
  19. }