Campbell Ritchie wrote:There is something wrong with a moveTo method taking such complicated arguments. Consider giving your Circle class moveRight and moveDown methods. You can move up and left by giving negative arguments. For example...will move the Circle about 14px in this direction: ⭩
14px ≈ 10 × √2.
But the code you posted earlier with calls to moveTo is modifying the state of a Circle object. If you have those constraints, you are going to have to think again. A moveTo method appears to be inconsistent with those constraints. Consider some other way to implement this, possible matching a Circle object with a Position object.Mike Mo wrote:. . . i def would have done this except that we are strictly for no reason at all allowed to change the circle class . . .
Campbell Ritchie wrote:
But the code you posted earlier with calls to moveTo is modifying the state of a Circle object. If you have those constraints, you are going to have to think again. A moveTo method appears to be inconsistent with those constraints. Consider some other way to implement this, possible matching a Circle object with a Position object.Mike Mo wrote:. . . i def would have done this except that we are strictly for no reason at all allowed to change the circle class . . .
I do not like assignments with such strict definitions; I believe the more is specified for you in advance, the less you will be able to do, and the less the assignment assesses your abilities.
i want it to move some distance that is pretty small then redraw and keep looping that movement until it reaches an edge.
Norm Radder wrote:
i want it to move some distance that is pretty small then redraw and keep looping that movement until it reaches an edge.
That implies some waiting between the drawing at the intermediate positions. Is there some delay mechanism in the given classes?
Campbell Ritchie wrote:It is really easy to make something move smoothly. Create a Swing Timer and add an ActionListener to it. The ActionListener causes your object to move a small distance, and you make the timer fire freuently; try once every 25ms. Read all about it in the Java™ Tutorials.
the other classes. my professor made them and told us we are to not alter them in any way for any reason
Norm Radder wrote:The code has many copies of these three lines. There should be a way to only have one set of these 3 lines:
How about outside of the switch
Norm Radder wrote:I think the Thread.sleep() method will work for you. The required catch block can be empty as you don't expect anything to interrupt the sleep
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |