clanecollege

Improved Rectangular Prism - RectPrism.java

May 16th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. // This builds on the original Rectprism.java.  Note that operations
  2. // such as calculating the volume and surface area have been implemented
  3. // in the class, and not in the main method.  This file is better practice.
  4.  
  5. public class ImprovedRectPrism
  6. {
  7.     int length = 0;
  8.     int width = 0;
  9.     int height = 0;
  10.  
  11.     public ImprovedRectPrism(int l, int w, int h)
  12.     {
  13.         this.length = l;
  14.         this.width = w;
  15.         this.height = h;
  16.     }
  17.  
  18.     public int getLength()
  19.     {
  20.         return length;
  21.     }
  22.  
  23.     public int getWidth()
  24.     {
  25.         return width;
  26.     }
  27.  
  28.     public int getHeight()
  29.     {
  30.         return height;
  31.     }
  32.    
  33.     public int calcVolume(){
  34.         return length * height * width;
  35.     }
  36.    
  37.     public int calcSurfaceArea(){
  38.         return 2*(width*length)+ 2*(length*width) +2*(length*height);
  39.     }
  40.    
  41.     /*
  42.      * implement setters etc.....
  43.      */
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment