/*
   This program reads in the dimensions of a box and then constructs
   a Box3 object that encapsulates the data for the box.

   Since the data fields of an object are private, this program uses
   "accessor methods" (i.e., get methods) to retrive data from the object.

   This program makes use of the fact that Box3 objects can compute their
   own volume and "length plus girth".
*/

public class UseBox3
{
   public static void main(String[] args)
   {
       Box3 box;  // declare a variable of type Box3

       System.out.println("This is UseBox3.\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 height: ");
          double height = MyInput.readDouble();
          System.out.print("Please enter the width: ");
          double width = MyInput.readDouble();
          System.out.print("Please enter the length: ");
          double length = MyInput.readDouble();

          // test if we are done
          if (height==0 || width==0 || length==0 )
          {  done = true; }
          else
          {
             // create a Box3 object with the appropriate
             // dimensions (using a constructor)  and name it box
             box = new Box3(height, width, length);

             // call a method that makes use of the data in the Box object
             doSomethingWithTheData( box );
          }
       }//while-loop
   }//main

   static void doSomethingWithTheData(Box3 box)
   {
      System.out.println();
      System.out.println("The dimensions of the box are");
      System.out.println("height is " + box.getHeight() + ",");
      System.out.println("width is " + box.getWidth() + ",");
      System.out.println("length is " + box.getLength() + ".");
      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

}//UseBox3