/**
 * Steven Ward
 * Utilities.java | Ship, CruiseShip, and CargoShip Classes Program
 *
 * This file defines a Utility class with a number of static methods for the program.
 *
 * Due Date: October 16, 2016
 *
 */

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;

/**
 * TODO: WRITE BRIEF DESCRIPTION OF UTILITY CLASS.
 * TODO: WRITE DETAILED DESCRIPTION OF UTILITY CLASS.
 *
 * TODO: COMPLETE CLASS DOCUMENTATION and TAGS.
 */
public class Utility {

  public static final int ALIGN_L = SwingConstants.LEFT;
  public static final int ALIGN_C = SwingConstants.CENTER;

  public static final int MESSAGE_Q = JOptionPane.QUESTION_MESSAGE;
  public static final int MESSAGE_E = JOptionPane.ERROR_MESSAGE;
  public static final int MESSAGE_I = JOptionPane.INFORMATION_MESSAGE;

  public static final int OPT_DEFAULT = JOptionPane.DEFAULT_OPTION;
  public static final int OPT_YNC = JOptionPane.YES_NO_CANCEL_OPTION;
  public static final int YES_OPT = JOptionPane.YES_OPTION;
  public static final int NO_OPT = JOptionPane.NO_OPTION;
  public static final int CLOSED = JOptionPane.CLOSED_OPTION;


  public static boolean tryParseInt(final String value) {
    try {
      Integer.parseInt(value);
      return true;
    }
    catch (NumberFormatException nfe) {
      return false;
    }
  }


  public static boolean isValidYear(final String yearStr) {
    try {
      int year = Integer.parseInt(yearStr);  // a valid yearStr can be parsed as an int value
      return ( year > 999 && year < 2017 ) ? true : false;  // a valid yearStr satisfies: 999 < year < 2017
    }
    catch (NumberFormatException nfe) {
      return false;
    }
  }


  public static JLabel format(int textWidth, final String str, int orientation) {
    final String htmlTags = "<html><body style='width: " + textWidth + "px'>";
    return new JLabel(htmlTags + str, orientation);
  }
}

@@ -523,98 +523,107 @@
 int 
-ALIGN_L = SwingConstants.LEFT;%0A  public static final int ALIGN_C = SwingConstants.CENTER;%0A
+WRAP = 650;%0A%0A  /** Aliases for several constants defined in the 'javax.swing.JOptionPane' class. */
 %0A  p
@@ -649,17 +649,16 @@
 int 
-MESSAGE_Q
+QUESTION
  = J
@@ -716,17 +716,13 @@
 int 
-MESSAGE_E
+ERROR
  = J
@@ -777,17 +777,12 @@
 int 
-MESSAGE_I
+INFO
  = J
@@ -813,17 +813,16 @@
 ESSAGE;%0A
-%0A
   public
@@ -843,19 +843,15 @@
 int 
-OPT_DEFAULT
+WARNING
  = J
@@ -865,23 +865,25 @@
 ane.
-DEFAULT_OPTION;
+WARNING_MESSAGE;%0A
 %0A  p
@@ -909,15 +909,11 @@
 int 
-OPT_YNC
+YES
  = J
@@ -931,25 +931,48 @@
 YES_
-NO_CANCEL
+OPTION;  // same value as 'OK
 _OPTION
-;
+', 0
 %0A  p
@@ -994,23 +994,18 @@
 nal int 
-YES_OPT
+NO
  = JOpti
@@ -1003,35 +1003,34 @@
 O = JOptionPane.
-YES
+NO
 _OPTION;%0A  publi
@@ -1048,22 +1048,22 @@
 nal int 
-NO_OPT
+CANCEL
  = JOpti
@@ -1061,34 +1061,38 @@
 L = JOptionPane.
-NO
+CANCEL
 _OPTION;%0A  publi
@@ -1686,32 +1686,515 @@
 se;%0A    %7D%0A  %7D%0A%0A%0A
+  public static boolean confirmExit() %7B%0A    final int optionType = JOptionPane.OK_CANCEL_OPTION;%0A    final String prompt = %22Are you sure you want to quit?%22;%0A    final String title = %22Exit?%22;%0A    Object%5B%5D choices = %7B %22Quit%22, %22Resume%22 %7D;%0A%0A    final int opt = JOptionPane.showOptionDialog( null, format(Utility.WRAP, prompt, SwingConstants.LEFT)%0A        , title, optionType, Utility.WARNING, null, choices, choices%5B1%5D );%0A%0A    return (opt == Utility.YES %7C%7C opt == Utility.CLOSED);%0A  %7D%0A%0A%0A
   public static 

Add 'Utility.java' with complete code (for now), although more may need to be added later on.