/******************************************************************
 * PhysicsTester is a class designed to exercise the methods of the
 * Physics class. 
 *
 * @author Nancy Harris, James Madison University
 * @version V1 - 9/30/2010
 ******************************************************************/
public class PhysicsTester
{
   /***************************************************************
    * main - entry point to the application
    *
    * @param command Command line arguments, unused in this app
    **************************************************************/
   public static void main (String [] command)
   {
      // check the falling distance
      checkExpect(Physics.getFallDistance(1), 4.9);
      checkExpect(Physics.getFallDistance(2), 19.6);
      System.out.println();
      
      // check the getDistance method
      checkExpect(Physics.getDistance(1, 1), 1);
      checkExpect(Physics.getDistance(60, 25), 1500);
      System.out.println();
      
      // check the getKinEnergy method
      checkExpect(Physics.getKinEnergy(100, 25), 31250.0);
      System.out.println();
      
      // check the getMomentum method
      checkExpect(Physics.getMomentum(100, 25), 2500);
      System.out.println();
      
      // check the getFinalVelocity method
      checkExpect(Physics.getFinalVelocity(25.5, 5, 10), 75.5);
      System.out.println();
      
      // check the getFormattedValue method
      checkExpect(Physics.getFormattedValue(3.14159, 2), "3.14");
   }
   
   /***************************************************************
    * checkExpect takes in two double values and prints a message
    * whether or not the two values are the same within a precision 
    * .001.
    ***************************************************************/
    public static void checkExpect(double check, double expect)
    {
      if (Math.abs(check - expect) <= .001)
         System.out.println("Your value " + check + " matches " + 
          "the expected value " + expect);
      else
         System.out.println("Your value " + check + " does not match " + 
          "the expected value " + expect);
    }
    /***************************************************************
    * checkExpect takes in two String values and prints a message
    * whether or not the two values are the same.
    ***************************************************************/
    public static void checkExpect(String check, String expect)
    {
      if (check.equals(expect))
         System.out.println("Your value " + check + " matches " + 
          "the expected value " + expect);
      else
         System.out.println("Your value " + check + " does not match " + 
          "the expected value " + expect);
    }
 }