I have an array of colours of size n. In my program, the number of teams is always <= n, and I need to assign each team a unique color. This is my color array:
If you want your NamedColor to be used as a java.awt.Color and you don't have many colors you can extend it and store the name.
public class NamedColor extends java.awt.Color {
private String name;
public NamedColor(String name, java.awt.Color c) {
super(c.getRGB());
this.name = name;
}
public String toString() {
return name;
}
}