/**
     * Check if the given rectangle collides with rectangles in the
     * {@link CollisionMap}.
     *
     * @param rectangle the rectangle to check for collision
     * @return true if the given rectangle intersects one of the rectangles in the
     *         collision map.
     * @throws IllegalArgumentException if rectangle is null
     */
public boolean collide(final Rectangle rectangle) {
        // TODO Insert code for assignment 5.2.c
        if(rectangle == null){
            throw new IllegalArgumentException("rectangle is null");
        }
        boolean flag = false;
        try{
            Set<Rectangle> rectangleSet = this.getCollisionCandidates(rectangle);
            for(Rectangle re:rectangleSet){
                if(re.intersects(rectangle)){
                    flag = true;
                }
            }
        }catch (Exception e){
            System.out.println(e.getMessage());
        }finally {
            return flag;
        }
    }
public boolean collide(final Rectangle rectangle) {
// TODO Insert code for assignment 5.2.c
if(rectangle == null){
throw new IllegalArgumentException("rectangle is null");
}
boolean flag = false;
try{
Set<Rectangle> rectangleSet = this.getCollisionCandidates(rectangle);
for(Rectangle re:rectangleSet){
if(re.intersects(rectangle)){
flag = true;
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}finally {
return flag;
}
}
public boolean collide(final Rectangle rectangle) {
// TODO Insert code for assignment 5.2.c
if(rectangle == null){
throw new IllegalArgumentException("rectangle is null");
}
boolean flag = false;
try{
Set<Rectangle> rectangleSet = this.getCollisionCandidates(rectangle);
for(Rectangle re:rectangleSet){
if(re.intersects(rectangle)){
flag = true;
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}finally {
return flag;
}
}
public boolean collide(final Rectangle rectangle) {
// TODO Insert code for assignment 5.2.c
if(rectangle == null){
throw new IllegalArgumentException("rectangle is null");
}
boolean flag = false;
try{
Set<Rectangle> rectangleSet = this.getCollisionCandidates(rectangle);
for(Rectangle re:rectangleSet){
if(re.intersects(rectangle)){
flag = true;
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}finally {
return flag;
}
}