/** Report on a round of golf at St. Andy’s. 
 *
 *  Taken from Core Web Programming from 
 *  Prentice Hall and Sun Microsystems Press,
 *  http://www.corewebprogramming.com/.
 *  &copy; 2001 Marty Hall and Larry Brown;
 *  may be freely used or adapted. 
 */

public class Golf {
  public static void main(String[] args) {
    int[] pars   = { 4,5,3,4,5,4,4,3,4 };
    int[] scores = { 5,6,3,4,5,3,2,4,3 };
    report(pars, scores);
  }

  /** Reports on a short round of golf. */

  public static void report(int[] pars, int[] scores) {
    for(int i=0; i<scores.length; i++) {
      int hole = i+1;
      int difference = scores[i] - pars[i];
      System.out.println("Hole " + hole + ": " +
                         diffToString(difference));
    }
  }

  /** Convert to English. */

  public static String diffToString(int diff) {
    String[] names = {"Eagle", "Birdie", "Par", "Bogey",
                      "Double Bogey", "Triple Bogey", "Bad"};
    // If diff is -2, return names[0], or "Eagle".
    int offset = 2;
    return(names[offset + diff]);
  }
}