private void fillCollisionMap(Set<Rectangle> rectangles) throws CollisionMapOutOfBoundsException {
        // TODO Insert code for assignment 5.2.a
        for(Rectangle rectangle:rectangles){
            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");
            }
            int startX = (int)transformX(rectangle.getX());
            int startY = (int)transformY(rectangle.getY());
            int endX = (int)transformX(rectangle.getX() + rectangle.getWidth());
            if(endX == this.GRID_RESOLUTION_X){
                endX = this.GRID_RESOLUTION_X - 1;
            }
            int endY = (int)transformY(rectangle.getY() + rectangle.getHeight());
            if(endY == this.GRID_RESOLUTION_Y){
                endY = this.GRID_RESOLUTION_Y - 1;
            }
            for(int i = startX; i <= endX; i++){
                for(int j = startY; j<=endY; j++){
                    map[j][i].add(rectangle);
                }
            }
        }
    }
private void fillCollisionMap(Set<Rectangle> rectangles) throws CollisionMapOutOfBoundsException {
       
        for(Rectangle rectangle:rectangles){
            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");
            }
            int startX = (int)transformX(rectangle.getX());
            int startY = (int)transformY(rectangle.getY());
            int endX = (int)transformX(rectangle.getX() + rectangle.getWidth());
            if(endX == this.GRID_RESOLUTION_X){
                endX = this.GRID_RESOLUTION_X - 1;
            }
            int endY = (int)transformY(rectangle.getY() + rectangle.getHeight());
            if(endY == this.GRID_RESOLUTION_Y){
                endY = this.GRID_RESOLUTION_Y - 1;
            }
            for(int i = startX; i <= endX; i++){
                for(int j = startY; j<=endY; j++){
                    map[j][i].add(rectangle);
                }
            }
        }
    }
private void fillcollisionmap(set<rectangle> rectangles) throws collisionmapoutofboundsexception { for(rectangle rectangle:rectangles){ 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"); } int startx = (int)transformx(rectangle.getx()); int starty = (int)transformy(rectangle.gety()); int endx = (int)transformx(rectangle.getx() + rectangle.getwidth()); if(endx == this.grid_resolution_x){ endx = this.grid_resolution_x - 1; } int endy = (int)transformy(rectangle.gety() + rectangle.getheight()); if(endy == this.grid_resolution_y){ endy = this.grid_resolution_y - 1; } for(int i = startx; i <= endx; i++){ for(int j = starty; j<=endy; j++){ map[j][i].add(rectangle); } } } }