class ResistorColor {
private static final String[] colorArray;
colorArray = new String[]{"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"};
int colorCode(String color) {
int index = 0;
for(int i = 0;i < colorArray.length;i++)
{
if(color.equals(colorArray[i]))
index = i;
}
return index;
}
String[] colors() {
return colorArray;
}
}
class ResistorColor {
static List<String> colors = Arrays.asList("black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white");
// function to return colorCode and takes in String color
int colorCode(String color) {
return colors.indexOf(color);
}
// function to return colorsArray
String[] colors() {
return (String[]) colors.toArray(new String[0]);
}
}