/*
   This file defines Box4 objects.

   A Box4 object holds the data that describes a real box.
   The data is private, so the data can only be manipulated
   through methods that belong to the object.

   A Box4 object is "immutable", that is, once a Box4 object is
   created, it cannot be changed.

   A Box4 object knows to label its largest dimension as its length.

   A Box4 object knows how to compute its volume and its
   "length plus girth".

   A Box4 object knows how to return a printable description
   of itself.
*/

class Box4
{
   // three (private) instance variables
   private double length;
   private double width;
   private double height;

   // define a constructor
   public Box4(double dimension1, double dimension2, double dimension3)
   {
       length = dimension1;
       width = dimension2;
       height = dimension3;

       // the length should be the largest
       // dimension of the box
       if (width > length)
       {
          // if width is larger than length
          // then swap the two values
          double temp = length;
          length = width;
          width = temp;
       }
       if (height > length)
       {
          // if height is larger than length
          // then swap the two values
          double temp = length;
          length = height;
          height = temp;
       }
   }//Box4 constructor

   // define three "get methods", one for each
   // field of the class
   public double getLength()
   {
      return length;
   }//getLength

   public double getWidth()
   {
      return width;
   }//getWidth

   public double getHeight()
   {
      return height;
   }//getHeight

   // define a method for computing the volume of the box
   public double volume()
   {
      return height*width*length;
   }//volume

   // define a method to compute "length plus girth"
   public double lengthPlusGirth()
   {
       return length+2*width+2*height;
   }//lengthPlusGirth

   // define a toString method
   public String toString()
   {
       return "The dimensions of the box are\n"
               + "height is " + height + ",\n"
               + "width is " + width + ",\n"
               + "length is " + length + ".";
    }//toString

}//Box3