   import java.awt.Color;
   import java.io.*;
   import java.util.Scanner;
   import java.util.Vector;

/**
 * A class that can be used to retrieve Color objects
 * by name (using the W3C names defined in
 * http://www.w3.org/TR/2003/CR-css3-color-20030514/ )
 */
    public class ColorFinder_Part5 
   {
      private Vector<Color>        colors;       
      private Vector<String>        names;
   
    /**
     * Default Constructor
     */
       public ColorFinder() throws IOException
      {
         Color          value;       
         int            blue, green, red;       
         Scanner        in;
         String         key;
       
       
         colors = new Vector<Color>();   
         names  = new Vector<String>();
       
         in = new Scanner(new File("colors.txt"));
      
         for (int i=0; in.hasNext(); i++)
         {
            key       = in.next();
            red       = in.nextInt();
            green     = in.nextInt();
            blue      = in.nextInt();
            value     = new Color(red, green, blue);          
         
            names.add(key);
            colors.add(value);          
         }
      }
   
   
    /**
     * Get the Color with the given name/description
     *
     * @param   description  The name/description of the Color
     * @return               The Color (or null if no such name exists)
     */
       public Color getColor(String description)
      {
         Color          result;
         String 			key;       
         
         result = null;
      	 // Add your code here
       
         for (int i=0; i<names.size() && result==null; i++) 
         { 
            key = (String) names.elementAt(i); 
            if (description.equals(key)) 
            {
               result =(Color) colors.elementAt(i);
            } 
         } // end for
      
      
      
      
         return result;       
      }// end getColor
    
   }// end class
