
// easy to add enumeration capability
class color8 {
  private final String id;
  private final int ord;
  private color8 next;
  private color8 prev;

  private static int upperBound = 0;
  private static color8 first = null;
  private static color8 last = null;

  private color8(String mid) {
    id=mid;
    ord=upperBound++;
    if(first==null) first=this;
    if(last!=null) {
      this.prev=last;
      last.next=this;
    }
    last=this;
  }
  public String toString() {return id;}
  public int ord() {return ord;}
  public color8 next() {return next;}
  public color8 prev() {return prev;}

  public static int size() {return upperBound;}
  public static color8 first() {return first;}
  public static color8 last() {return last;}
  public static Enumeration elements() {
    return new Enumeration() {
      private color8 curr=first;
      public boolean hasMoreElements() {
        return curr!=null;
      }
      public Object nextElement() {
        color8 c=curr;
        curr=curr.next;
        return c;
      }
    };
  }

  public static final color8 RED = new color8("red");
  public static final color8 GREEN = new color8("green");
  public static final color8 BLUE = new color8("blue");
}

