boolean intersects(Rect other) {
    return !(this.coordinateX + this.width / 2 <= other.coordinateX - other.width / 2
        || this.coordinateX - this.width / 2 >= other.coordinateX + other.width / 2
        || this.coordinateY + this.height / 2 <= other.coordinateY - other.height / 2
        || this.coordinateY - this.height / 2 >= other.coordinateY + other.height / 2);
  }
@Test
  void intersectsTest() {
    var r1 = new Rect(10, 10, 20, 20);
    var r2 = new Rect(15, 15, 20, 20);
    var r3 = new Rect(50, 50, 20, 20);
    //r1 intersects r2 and not r3
    assertTrue(r1.intersects(r2));
    assertFalse(r1.intersects(r3));
  }