private Set<Rectangle> getCollisionCandidates(final Rectangle rectangle) throws CollisionMapOutOfBoundsException {
        // TODO Insert code for assignment 5.2.b
        if(
                rectangle.getX() < this.gridRectangle.getX() ||
                rectangle.getX() + rectangle.getWidth() > this.gridRectangle.getX() + this.gridRectangle.getWidth() ||
                rectangle.getY() < this.gridRectangle.getY() ||
                rectangle.getY() + rectangle.getHeight() > this.gridRectangle.getY() + this.gridRectangle.getHeight()
        ){
            throw new CollisionMapOutOfBoundsException("a rectangle is out of the bounds of this rectangle");
        }
        Set<Rectangle> rectangleSet = new HashSet<>();
        int startX = (int)transformX(rectangle.getX());
        int startY = (int)transformY(rectangle.getY());
        int endX = (int)transformX(rectangle.getX() + rectangle.getWidth()) + 1;
        int endY = (int)transformY(rectangle.getY() + rectangle.getHeight()) + 1;
        for(int i = startX; i <= endX; i++){
            for(int j = startY; j<=endY; j++){
                for(Rectangle re :map[j][i]){
                    rectangleSet.add(re);
                }
            }
        }
        return rectangleSet;
    }
private Set<Rectangle> getCollisionCandidates(final Rectangle rectangle) throws CollisionMapOutOfBoundsException {
       
        if(
                rectangle.getX() < this.gridRectangle.getX() ||
                rectangle.getX() + rectangle.getWidth() > this.gridRectangle.getX() + this.gridRectangle.getWidth() ||
                rectangle.getY() < this.gridRectangle.getY() ||
                rectangle.getY() + rectangle.getHeight() > this.gridRectangle.getY() + this.gridRectangle.getHeight()
        ){
            throw new CollisionMapOutOfBoundsException("a rectangle is out of the bounds of this rectangle");
        }
        Set<Rectangle> rectangleSet = new HashSet<>();
        int startX = (int)transformX(rectangle.getX());
        int startY = (int)transformY(rectangle.getY());
        int endX = (int)transformX(rectangle.getX() + rectangle.getWidth()) + 1;
        int endY = (int)transformY(rectangle.getY() + rectangle.getHeight()) + 1;
        for(int i = startX; i <= endX; i++){
            for(int j = startY; j<=endY; j++){
                for(Rectangle re :map[j][i]){
                    rectangleSet.add(re);
                }
            }
        }
        return rectangleSet;
    }
private set<rectangle> getcollisioncandidates(final rectangle rectangle) throws collisionmapoutofboundsexception { if( rectangle.getx() < this.gridrectangle.getx() || rectangle.getx() + rectangle.getwidth() > this.gridrectangle.getx() + this.gridrectangle.getwidth() || rectangle.gety() < this.gridrectangle.gety() || rectangle.gety() + rectangle.getheight() > this.gridrectangle.gety() + this.gridrectangle.getheight() ){ throw new collisionmapoutofboundsexception("a rectangle is out of the bounds of this rectangle"); } set<rectangle> rectangleset = new hashset<>(); int startx = (int)transformx(rectangle.getx()); int starty = (int)transformy(rectangle.gety()); int endx = (int)transformx(rectangle.getx() + rectangle.getwidth()) + 1; int endy = (int)transformy(rectangle.gety() + rectangle.getheight()) + 1; for(int i = startx; i <= endx; i++){ for(int j = starty; j<=endy; j++){ for(rectangle re :map[j][i]){ rectangleset.add(re); } } } return rectangleset; }