Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I can move the circle any where I want. But When I move the square its suppose t

ID: 3620578 • Letter: I

Question

I can move the circle any where I want. But When I move the square its suppose to drag both objects together. HOwever, when moving the sqaure, both objects should move even if the circle has already been moved. PROBLEM: Moved the ellipse.. Then moving the rectangle the ellipse snaps back to the rectangle. I believe it needs a move method or something and not a setLocation..
I can move the circle any where I want. But When I move the square its suppose to drag both objects together. HOwever, when moving the sqaure, both objects should move even if the circle has already been moved. PROBLEM: Moved the ellipse.. Then moving the rectangle the ellipse snaps back to the rectangle. I believe it needs a move method or something and not a setLocation..

Explanation / Answer

Solution: In your Hat class, take out this line in the setLocation method: _bcHat.setLocation(x + 50 , y); In your mousePressed method, add this line: _bcHat.mousePressed(e); In your mouseDragged method, add this line: _bcHat.mouseDragged(e); Basically, everytime you press on the hat, it will also press on the ellipse and everytime you drag the hat, it will also drag the ellipse.