silentkiler029

Box.java

Dec 5th, 2021
596
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Practice;
  2.  
  3. public class Box {
  4.     double height;
  5.     double width;
  6.     double length;
  7.  
  8.     // constructor - no return type
  9.     Box( double l, double w, double h ) {
  10.         height = h;
  11.         width = w;
  12.         length = l;
  13.     }
  14.  
  15.     // Constructor Overloading
  16.     Box() {
  17.         height = -1;
  18.         width = -1;
  19.         length = -1;
  20.     }
  21.     Box( double val ) {
  22.         height = width = length = val;
  23.     }
  24.  
  25.     void setValues( double l, double w, double h ) {
  26.         length = l;
  27.         width = w;
  28.         height = h;
  29.     }
  30.  
  31.     double getVolume() {
  32.         return height * width * length;
  33.     }
  34. }
  35.  
RAW Paste Data