Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This builds on the original Rectprism.java. Note that operations
- // such as calculating the volume and surface area have been implemented
- // in the class, and not in the main method. This file is better practice.
- public class ImprovedRectPrism
- {
- int length = 0;
- int width = 0;
- int height = 0;
- public ImprovedRectPrism(int l, int w, int h)
- {
- this.length = l;
- this.width = w;
- this.height = h;
- }
- public int getLength()
- {
- return length;
- }
- public int getWidth()
- {
- return width;
- }
- public int getHeight()
- {
- return height;
- }
- public int calcVolume(){
- return length * height * width;
- }
- public int calcSurfaceArea(){
- return 2*(width*length)+ 2*(length*width) +2*(length*height);
- }
- /*
- * implement setters etc.....
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment