/* @(#)Images.java 1.0 for web images 15 November 2004 */

import java.awt.*;
import java.net.*;
import javax.swing.*;

/**
 * <p>The class Images encapsulated how the Concentration Game
 * obtains its images.</p>
 * 
 * <p>This version of the class is designed for use with the
 * ConcentrationApplet as installed on the JPT web site.</p>
 */
public class images {
    
    private static String imagesURL  =
        "http://www.ccs.neu.edu/home/bschory/applet/images/";

    private static String fileListName = "ImageNames.txt";
    
    
    public static Image[] getImages() {
        try {
            imagesURL = WebTools.appendSlashIfNeeded(imagesURL);
            
            String[] list = WebTools.readFileNamesFromWeb
            	(imagesURL, fileListName);
            
            int length = list.length;
            
            Image[] images = new Image[length];
            
            for (int i = 0; i < length; i++) {
                URL url = new URL(imagesURL + list[i]);
                ImageIcon imageicon = new ImageIcon(url);
                images[i] = imageicon.getImage();
            }
            
            return images;
        }
        catch (Exception ex) {
            return new Image[0];
        }
    }
    
    
    public static void setImagesURL(String url) {
        if ((url != null) && (url.length() > 0))
            imagesURL = url;
    }
}