Square[] testSquares = new Square[3];
public SquareTester (){
for(int i = 0; i < testSquares.length; i++){
testSquares[i] = new Square();
}
}
public void paint(Graphics g) {
for (int i = 0; i<testSquares.length; i++){
testSquares[i].display(g);
}
if (testSquares[0].overlaps(testSquares[1])) {
testSquares[0].changeColor(Color.YELLOW);
testSquares[1].changeColor(Color.GREEN);
g.setFont(new Font ("Comic Sans", Font.BOLD,35));
g.drawString("HOLA, IT OVERLAPPED!", 0, 600);
}
}
Above is the code that makes the array of squares, and changes color when two of them overlap. I want to change this code so that it changes color if any of the squares in the whole array are overlapping. (My overlaps method is done already. No need to code that.)