/*
   This program reads in the dimensions of a box and then constructs
   a Box4 object that encapsulates the data for the box.

   This program makes use of the fact that a Box4 object knows to
   label its largest dimension as its length.

   This program makes use of the fact that a Box4 object knows how to
   provide a printable description of itself.

   Finally, notice that as the length of the Box classes grew longer, the
   length of the UseBox programs grew shorter. Complexity was moved from the
   programs into the objects that the programs used.
*/

public class UseBox4
{
   public static void main(String[] args)
   {
       Box4 box;  // declare a variable of type Box4

       System.out.println("This is UseBox4.\n");

       boolean done = false;
       while( !done )
       {
          // get data from the keyboard operator
          System.out.println("Please enter the dimensions of the box.");
          System.out.print("Please enter the first dimension: ");
          double dim1 = MyInput.readDouble();
          System.out.print("Please enter the second dimension: ");
          double dim2 = MyInput.readDouble();
          System.out.print("Please enter the third dimension: ");
          double dim3 = MyInput.readDouble();

          // test if we are done
          if (dim1==0 || dim2==0 || dim3==0 )
          {  done = true; }
          else
          {
             // create a Box4 object with the appropriate
             // dimensions (using a constructor)  and name it box
             box = new Box4(dim1, dim2, dim3);

             // call a method that makes use of the data in the Box object
             doSomethingWithTheData( box );
          }
       }//while-loop
   }//main

   static void doSomethingWithTheData(Box4 box)
   {
      System.out.println();
      System.out.println(box);
      System.out.println("The volume of the box is " + box.volume() + ".");
      System.out.println("The length plus girth of the box is " + box.lengthPlusGirth() + ".");
      System.out.println();
   }//doSomethingWithTheData

}//UseBox4