/**
 * This class contains methods that are to be tested as part of Lab09B.
 * 
 * Method documentation for the first three methods has been omitted, since they are to
 * be tested with "white-box" techniques, rather than by using documentation.
 * 
 * @author R.Grove
 * @version 1.0  10/22/2012
 */
public class Lab09B {
  
  public static int ifMethod(int a, int b, int c) {
    if (a < 0) {
      return 1;
    }
    else if (b + a == 3) {
      return 2;
    }
    else if (a + b + c > 10) {
      return 3;
    }
    return 0;
  }
  
  public static String caseMethod(int code) {
    String returnValue;
    returnValue = "Unknown";
    
    switch (code) {
      case 100:
        returnValue = "Information";
        break;
      case 200:
        returnValue = "Success";
        break;
      case 404:
        returnValue = "Unknown URL";
        break;
      case 505:
        returnValue = "Server Error";
        break;
    }
    
    return returnValue;
  }
  
  public static int loopMethod(int size) {
    int sum = 0;
    for (int i=1; i<size; i++) {
      if (size % i == 0) {
        sum = sum + i;
      } 
    }
    return sum;
  }
  
  /**
   * This method returns the square root of non-negative value of x, to a precision of 0.00001. For negative values,
   * the method returns 0;
   * 
   * @param x The number for which the square root is to be computed.
   * @return The square root of the parameter, x.
   */
  public static double squareRoot(double x) {
    double root;
    root = x < 0 ? 0 : x / 2.0;
    while(x >= 0 && Math.abs(root * root - x) > 0.00001) {
      root = (root + x / root) / 2.0;
    }
    return root;
  }
  
} // end class Lab09B