RoundedRectangle's setWidth() and setHeight() don't update maxX and maxY

Issue #41 new
Joshua Hertlein created an issue

Reproduction steps:

RoundedRectangle r = new RoundedRectangle(0, 0, 10, 10, 1);
System.out.println("15, 15 is in shape: " + r.contains(15, 15)); //shouldn't be inside it, is not inside it
r.setWidth(30);
r.setHeight(30);
System.out.println("15, 15 is in shape: " + r.contains(15, 15)); //should be inside it, is not inside it

//workaround
r = new RoundedRectangle(0, 0, 30, 30, 1);
System.out.println("15, 15 is in shape: " + r.contains(15, 15)); //works

I looked through the code, and I think this issue is because RoundedRectangle doesn't correctly override setWidth and setHeight- comparing it to the implementation in Rectangle, it should be updating maxX and maxY, but it doesn't.

Comments (2)

  1. Log in to comment