I have two questions:
-
If I have the following code:
private boolean handleCollision(Rectangle_Double test) { Rectangle_Double s = test; s.setLocation(s.X+xVelocity, s.Y); }
am I modifying the passed in Rectangle_Double? If so, what would be the best way to copy the passed in Rectangle_Double and modify it?
Second, If I were to code this in python like so:
def handleCollision(collidedLands, testRectangle)
s = testRectangle
s.setLocation(s.X+xVelocity, s.Y)
am I modifying the passed in testRectangle? If so, what would be the best way to copy the passed in testRectangle and modify it?
Thanks!
I don’t speak Java, but to answer the Python questions:
Yes, you are modifying testRectangle.
If you wish not to modify it, make a new rectangle and return that.
Something like this, assuming you have a constructor for rectangles: