Hi,
This may be a really basic query, but im not really a java expert! In my program, i am drawing rectangles and the colour of the rectangle depends on a number stored in an array, so if the number is 1 then i want to set the colour to red, if 2 then blue etc. I have to keep changing the colour a lot of times (atleast 10) so instead of writing a switch statement each time i have created the class below. The thins im having trouble calling the method in my main program. I have tried d.decide(A), but its not working. Am i calling it in the wrong way? Any help would be great!
Thanks!
import java.awt.*;
public class colors{
public Color decide(int a){
if(a==1){
return Color.red;
}
if(a==2){
return Color.blue;
}
if(a==3){
return Color.green;
}
if(a==4){
return Color.pink;
}
if(a==5){
return Color.yellow;
}
}
}