import java.awt.*;
import java.util.*;

public class Colors implements rgbsModel {
  
  Color colors[] = new Color[100];
  int current = 0;
  
  public void go(){
    current ++;
  }

  public void init(String s){
    int i = 0;
    colors[0] = Color.black;
    StringTokenizer st = new StringTokenizer(s,"|");
    try {
      while(st.hasMoreTokens() && i < colors.length){
	try {
	  StringTokenizer str = new StringTokenizer(st.nextToken(),",");
	  colors[i] = 
            new Color(
   Math.max(0, Math.min(255, (new Integer(str.nextToken())).intValue())),
   Math.max(0, Math.min(255, (new Integer(str.nextToken())).intValue())),
   Math.max(0, Math.min(255, (new Integer(str.nextToken())).intValue())));

	  i ++;
	} catch(Exception e){}      
      }
    } catch(Exception e){}
  }

  public Color getColor(){
    if(colors[current] == null){
      current = 0;
    }
    return colors[current];
  }
}

