/**
 * An example that illustrates an adequate but inflexible approach to
 * implementing a checklist.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class Inflexible {
    
    /**
     * The entry point.
     *
     * @param args  The command line arguments (ignored)
     */
    public static void main(String[] args) {
        String[] checklist = {"Shirts", "Socks", "Pants", "Skirts"};

        String[][] accomplished   = {
            {"Shirts", "Socks", "Pants", "Dresses", "Shoes"}, // false
            {"Socks", "Shirts", "Skirts", "Pants"},            // true
            {"Dresses", "Shirts", "Socks", "Pants", "Skirts"},  // true
        };

        boolean[] expected = {false, true, true};
        
                
        for (int i = 0; i < accomplished.length; i++) {
            System.out.println("Test " + i + " ---------------");
            if (checkFor(checklist, accomplished[i]) != expected[i]) {
                System.out.println("Incorrect answer for: " + i);
            }
        }
    }

//[0
    /**
     * An n out of n checklist.
     *
     * @param checklist  The checklist
     * @param accomplished  The array of accomplished items
     * @return true if the Checklist is satisfied; false otherwise
     */
    private static boolean checkFor(String[] checklist, String[] accomplished) {
        boolean checked;
        for (int c = 0; c < checklist.length; c++) {
            checked = false;

            for (int a = 0; a < accomplished.length; a++) {
                if (checklist[c].equals(accomplished[a])) {
                    checked = true;
                    break;
                }
            }            
            if (!checked) return false; // An item was not accomplished
        }
        return true; // All items were accomplished
    }
//]0
}
