Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>your coordinates are backwards: </p> <pre><code>-public void eraseCircle(Graphics g, int x, int y) -c.eraseCircle(g,temp.getY(),temp.getX()); </code></pre> <p>switch around x and y and it should work.</p> <p>Edit: Ok so the problem is the x and y in your coords are always 0 so I modified your drawCircle method to return the proper coordinates, and your paint method to store them, so this is what you get:</p> <p>Paint:</p> <pre><code>public void paint(Graphics g) { int incX = 5; // initial x increment for circle locations int incY = 5; // initial y increment for circle locations Coord temp = new Coord(0,0); Queue&lt;Coord&gt; q = new LinkedList&lt;Coord&gt;(); Circle c = new Circle(g,circleSize,incX,incY,TIME_DELAY); try { for(int i = 1; i &lt;= TOTAL_NUM_CIRCLES; i++) { if(q.size() &gt;= 50) { temp = q.remove(); c.eraseCircle(g,temp.getX(),temp.getY()); } temp = new Coord(getX(),getY()); //q.add(temp); q.add(c.drawCircle(g)); c.hitEdge(); } } catch(InterruptedException e){} } </code></pre> <p>drawCircle:</p> <pre><code>/** * draws a blue circle and sets the tlX and tlY for the next drawing * @param g Graphics object * @return */ public Coord drawCircle(Graphics g) throws InterruptedException { g.setColor(Color.blue); g.drawOval(tlX,tlY,size,size); delay(timeDelay); if (addX) tlX+=incX; else tlX-=incX; if (addY) tlY+=incY; else tlY-=incY; return new Coord(tlX, tlY); } </code></pre> <p>To determine this I set a breakpoint in the paint method and viewed what temp's values were through eclipses debugger.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload