import org.code.neighborhood.Painter;
public class MyNeighborhood {
public static void main(String[] args) {
String[] paintColors = new String[3];
String[] paintColors = {"Red", "White", "Blue"};
ArrayPainter myArrayPainter = new ArrayPainter(5, 0, "south", 18, paintColors);
myArrayPainter.moveAndPaint();
}
}
In the ArrayPainter subclass:
public class ArrayPainter extends Painter {
private String[] paintColors;
public ArrayPainter(int x, int y, String direction, int paint, String[] paintColors) {
super(x, y, direction, paint);
this.paintColors = paintColors;
}
public String[] getPaintColors() {
return paintColors;
}
public void moveAndPaint() {
int index = 0;
while(index < paintColors.length) {
move();
paint(paintColors[index]);
index++;
}
}
public void setColor(int index, String newColor) {
return paintColors[index] = newColor;
}
}
When I try to run my code, the error is within this line:
public void setColor(int index, String newColor) {
return paintColors[index] = newColor;
The goal of this method is to change one or more colors in the array.