public Rectangle getBounds() {
        double minX = Double.MAX_VALUE;
        double minY = Double.MAX_VALUE;
        double maxX = Double.MIN_VALUE;
        double maxY = Double.MIN_VALUE;

        for (LineSegment segment : this.segments) {
            minX = Math.min(minX, Math.min(segment.start.x, segment.end.x));
            minY = Math.min(minY, Math.min(segment.start.y, segment.end.y));
            maxX = Math.max(maxX, Math.max(segment.start.x, segment.end.x));
            maxY = Math.max(maxY, Math.max(segment.start.y, segment.end.y));
        }
        return new Rectangle(minX, minY, maxX, maxY);
    }
@Test
    public void boundsTest() {
        Point point1 = new Point(0, 0);
        Point point2 = new Point(1, 0);
        Point point3 = new Point(1, 1);

        LineString lineString = new LineString();
        lineString.segments.add(new LineSegment(point1, point2));
        lineString.segments.add(new LineSegment(point2, point3));

        Assert.assertEquals(new Rectangle(0, 0, 1, 1), lineString.getBounds());
    }