I'm a beginner to Java and was wondering if there is a way to rewrite the below code in 1 one line while keeping its functionality the same?
private boolean colour_chosen(Colour Colour, boolean red, boolean blue, boolean yellow) {
if (Colour instanceof redColour) {
if (red) return true;
else return false;
} else if (Colour instanceof blueColour) {
if (blue) return true;
else return false;
} else if (Colour instanceof yellowColour) {
if (yellow) return true;
else return false;
} else {
return false;
}
}